(t *testing.T)
| 102 | } |
| 103 | |
| 104 | func TestValidateKeyArgs(t *testing.T) { |
| 105 | pubKeyCWD := t.TempDir() |
| 106 | |
| 107 | err := validateKeyArgs("a", pubKeyCWD) |
| 108 | assert.NilError(t, err) |
| 109 | |
| 110 | err = validateKeyArgs("a/b", pubKeyCWD) |
| 111 | assert.Error(t, err, "key name \"a/b\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character") |
| 112 | |
| 113 | err = validateKeyArgs("-", pubKeyCWD) |
| 114 | assert.Error(t, err, "key name \"-\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character") |
| 115 | |
| 116 | assert.NilError(t, os.WriteFile(filepath.Join(pubKeyCWD, "a.pub"), []byte("abc"), notary.PrivExecPerms)) |
| 117 | err = validateKeyArgs("a", pubKeyCWD) |
| 118 | assert.Error(t, err, fmt.Sprintf("public key file already exists: \"%s\"", filepath.Join(pubKeyCWD, "a.pub"))) |
| 119 | |
| 120 | err = validateKeyArgs("a", "/random/dir/") |
| 121 | assert.Error(t, err, "public key path does not exist: \"/random/dir/\"") |
| 122 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…