check SSH key existence before uploading

This commit is contained in:
vaindil 2023-03-29 17:23:22 -04:00
parent 82662685e3
commit f21f1ca4ef
7 changed files with 130 additions and 37 deletions

View file

@ -38,6 +38,9 @@ func TestLogin_ssh(t *testing.T) {
tr.Register(
httpmock.GraphQL(`query UserCurrent\b`),
httpmock.StringResponse(`{"data":{"viewer":{ "login": "monalisa" }}}`))
tr.Register(
httpmock.REST("GET", "api/v3/user/keys"),
httpmock.StringResponse(`[]`))
tr.Register(
httpmock.REST("POST", "api/v3/user/keys"),
httpmock.StringResponse(`{}`))
@ -78,7 +81,7 @@ func TestLogin_ssh(t *testing.T) {
}
assert.Equal(t, expected, args)
// simulate that the public key file has been generated
_ = os.WriteFile(keyFile+".pub", []byte("PUBKEY"), 0600)
_ = os.WriteFile(keyFile+".pub", []byte("PUBKEY asdf"), 0600)
})
cfg := tinyConfig{}