Files
mfer/mfer/manifest_test.go
T
clawbot 5a88a52ab2
check / check (push) Waiting to run
Export the loaded manifest type as Manifest (closes #236)
Package mfer handed out a loaded manifest as the unexported type
manifest. Without a name for that type, a program using the library
could not keep a loaded manifest in a struct field or pass one to its
own functions. As sneak approved, the type is now exported as Manifest
with its fields kept private. Its existing methods (Files, Signer,
CreatedAt, String) are its whole API.

NewManifestFromReader and NewManifestFromFile return *Manifest. The two
lint suppressions that excused returning an unexported type from them
are removed. The type's doc comment now names the two loaders and drops
the pointer to the settled design question. String gets a doc comment.
A test in package mfer_test uses *mfer.Manifest from outside the
package.

Model: opus-5-5
2026-10-21 13:12:20 +02:00

31 lines
932 B
Go

//nolint:testpackage // white-box tests exercise unexported internals
package mfer
import (
"encoding/hex"
"testing"
"uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestSignatureString checks the canonical string for the UUID and sha256
// of the example in the Signature Scheme section of docs/FORMAT.md, which
// shows the same string.
func TestSignatureString(t *testing.T) {
t.Parallel()
manifestUUID := uuid.MustParse("b0fb6918-6298-443b-ada2-1b162f4dc0b3")
sha256Hash, err := hex.DecodeString(
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
require.NoError(t, err)
m := &Manifest{pbOuter: &MFFileOuter{Uuid: manifestUUID[:], Sha256: sha256Hash}}
got, err := m.signatureString()
require.NoError(t, err)
assert.Equal(t, "ZNAVSRFG-b0fb69186298443bada21b162f4dc0b3-"+
"1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", got)
}