github.com/thanos-io/thanos@v0.32.5/pkg/block/metadata/hash_test.go (about) 1 // Copyright (c) The Thanos Authors. 2 // Licensed under the Apache License 2.0. 3 4 package metadata 5 6 import ( 7 "os" 8 "testing" 9 10 "github.com/go-kit/log" 11 12 "github.com/efficientgo/core/testutil" 13 ) 14 15 func TestHashSmoke(t *testing.T) { 16 dir := t.TempDir() 17 f, err := os.CreateTemp(dir, "hash") 18 testutil.Ok(t, err) 19 20 _, err = f.Write([]byte("test")) 21 testutil.Ok(t, err) 22 23 exp := ObjectHash{Func: SHA256Func, Value: "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"} 24 h, err := CalculateHash(f.Name(), SHA256Func, log.NewNopLogger()) 25 testutil.Ok(t, err) 26 testutil.Equals(t, exp, h) 27 28 _, err = CalculateHash(f.Name(), NoneFunc, log.NewNopLogger()) 29 testutil.NotOk(t, err) 30 }