2017-05-25 01:31:52 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
2020-09-29 14:46:51 +02:00
|
|
|
"os"
|
2017-05-25 01:31:52 +02:00
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2020-09-29 14:46:51 +02:00
|
|
|
func TestPluginSHA256LockFile_Read(t *testing.T) {
|
2018-03-28 19:08:38 +02:00
|
|
|
f, err := ioutil.TempFile(testingDir, "tf-pluginsha1lockfile-test-")
|
2017-05-25 01:31:52 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to create temporary file: %s", err)
|
|
|
|
}
|
|
|
|
f.Close()
|
2020-09-29 14:46:51 +02:00
|
|
|
defer os.Remove(f.Name())
|
2017-05-25 01:31:52 +02:00
|
|
|
|
|
|
|
plf := &pluginSHA256LockFile{
|
|
|
|
Filename: f.Name(),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initially the file is invalid, so we should get an empty map.
|
|
|
|
digests := plf.Read()
|
|
|
|
if !reflect.DeepEqual(digests, map[string][]byte{}) {
|
|
|
|
t.Errorf("wrong initial content %#v; want empty map", digests)
|
|
|
|
}
|
|
|
|
}
|