github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/command/plugins_lock_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package command 5 6 import ( 7 "io/ioutil" 8 "os" 9 "reflect" 10 "testing" 11 ) 12 13 func TestPluginSHA256LockFile_Read(t *testing.T) { 14 f, err := ioutil.TempFile(t.TempDir(), "tf-pluginsha1lockfile-test-") 15 if err != nil { 16 t.Fatalf("failed to create temporary file: %s", err) 17 } 18 f.Close() 19 defer os.Remove(f.Name()) 20 21 plf := &pluginSHA256LockFile{ 22 Filename: f.Name(), 23 } 24 25 // Initially the file is invalid, so we should get an empty map. 26 digests := plf.Read() 27 if !reflect.DeepEqual(digests, map[string][]byte{}) { 28 t.Errorf("wrong initial content %#v; want empty map", digests) 29 } 30 }