Files
mfer/mfer/manifest_test.go
T
sneak 24487ce36a
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, so a program using the library could not name it, keep it in
a struct field or pass it to its own functions. As sneak approved, it is
now exported as Manifest with its fields kept private, so its existing
methods (Files, Signer, CreatedAt, String) are its whole API.

NewManifestFromReader and NewManifestFromFile return *Manifest, and the
lint suppressions for returning an unexported type are gone. The type's
doc comment no longer points at the settled design question, and String
has a doc comment. A new test in package mfer_test uses *mfer.Manifest
from outside the package.

Model: opus-5-5
2026-10-21 10:16:30 +00: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)
}