Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions tests/sshkey.bats
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
#!/usr/bin/env bats
load test-helper

@test "$clinom sshkey add \"test\"" {
run "${clicmd}" sshkey add "test"
assert_success && assert_output -p 'Added'
@test "$clinom sshkey add" {
run "${clicmd}" sshkey add
if [[ "$output" == *"invalid"* ]]; then
skip "Please provide a valid sshkey"
fi
assert_success && assert_output -p 'Added sshkey'
}

@test "$clinom sshkey list" {
run "${clicmd}" sshkey list
assert_success && assert_output -p 'test'
assert_success
}

@test "$clinom sshkey delete \"test\"" {
run "${clicmd}" sshkey delete "test"
assert_success && assert_output -p 'deleted'
@test "$clinom sshkey delete" {
run "${clicmd}" sshkey delete
if [[ "$output" == *"Error"* ]]; then
skip "Please provide a valid sshkey"
fi
assert_success && assert_output -p 'Deleted sshkey'
}

@test "$clinom sshkey deleteall (manually test w/out bats - deletes all sshkeys)" {}
@test "$clinom sshkey deleteall" {
skip "Run $clinom sshkey deleteall manually for testing"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if @dogi wants the test to delete all ssh keys anyway since this test will be ran on a 'goner' anyway.

run "${clicmd}" sshkey deleteall
[ "$status" -eq 0 ]
}

@test "$clinom sshkey github adduser dogi" {
@test "$clinom sshkey github adduser" {
run "${clicmd}" sshkey github adduser dogi
if [[ "$output" == *"Error"* ]]; then
skip "Please provide a valid Github username"
fi
assert_success
}

@test "$clinom sshkey github deleteuser dogi" {
@test "$clinom sshkey github deleteuser" {
run "${clicmd}" sshkey github deleteuser dogi
if [[ "$output" == *"Error"* ]]; then
skip "Please provide a valid Github username"
fi
assert_success
}

@test "$clinom sshkey github addteam (manually test w/out bats - needs access token)" {}
@test "$clinom sshkey github addteam" {
run "${clicmd}" sshkey github addteam
if [[ "$output" == *"Error"* ]]; then
skip "Please provide arguments: <organization> <team_name> <access_token>"
fi
assert_success
}