github.com/cycloidio/terraform@v1.1.10-0.20220513142504-76d5c768dc63/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(testingDir, "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  }