35 lines
698 B
Go
35 lines
698 B
Go
package assets
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestInfo(t *testing.T) {
|
|
dir := t.TempDir()
|
|
p := filepath.Join(dir, "sample.bin")
|
|
data := []byte("rk3588-assets")
|
|
if err := os.WriteFile(p, data, 0o644); err != nil {
|
|
t.Fatalf("write file: %v", err)
|
|
}
|
|
|
|
got, err := Info(p)
|
|
if err != nil {
|
|
t.Fatalf("info: %v", err)
|
|
}
|
|
h := sha256.Sum256(data)
|
|
wantSha := hex.EncodeToString(h[:])
|
|
if got.Sha256 != wantSha {
|
|
t.Fatalf("sha256 mismatch: got %s want %s", got.Sha256, wantSha)
|
|
}
|
|
if got.Size != int64(len(data)) {
|
|
t.Fatalf("size mismatch: got %d want %d", got.Size, len(data))
|
|
}
|
|
if got.MtimeMS == 0 {
|
|
t.Fatalf("mtime not set")
|
|
}
|
|
}
|