github.com/justincormack/cli@v0.0.0-20201215022714-831ebeae9675/cli/command/trust/helpers_test.go (about) 1 package trust 2 3 import ( 4 "io/ioutil" 5 "os" 6 "testing" 7 8 "github.com/theupdateframework/notary/client" 9 "github.com/theupdateframework/notary/passphrase" 10 "github.com/theupdateframework/notary/trustpinning" 11 "gotest.tools/v3/assert" 12 ) 13 14 func TestGetOrGenerateNotaryKeyAndInitRepo(t *testing.T) { 15 tmpDir, err := ioutil.TempDir("", "notary-test-") 16 assert.NilError(t, err) 17 defer os.RemoveAll(tmpDir) 18 19 notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{}) 20 assert.NilError(t, err) 21 22 err = getOrGenerateRootKeyAndInitRepo(notaryRepo) 23 assert.Error(t, err, "client is offline") 24 }