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