Skip to content
Open
Changes from 1 commit
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
46 changes: 46 additions & 0 deletions tests/config.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bats
load test-helper

@test "$clinom config" {
skip "Run $clinom config with the [update|add|delete|clear] subcommands"
Copy link
Member

Choose a reason for hiding this comment

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

This test could check for the 2 possible outputs of treehouses config:

Error: config file is empty; no variables to show

CONFIG_NAME=VARIABLE

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

@test "$clinom config update" {
run "${clicmd}" config update abc 123
if [[ "$output" == *"Error"* ]]; then
skip "Missing varname or varvalue"
fi
Copy link
Member

Choose a reason for hiding this comment

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

This test could create a fake config variable like an apitoken for Gitter/Discord/Slack.

assert_success
}

@test "$clinom config add" {
run "${clicmd}" config add abc 123
if [[ "$output" == *"Error"* ]]; then
skip "Missing varname or varvalue"
fi
Copy link
Member

Choose a reason for hiding this comment

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

This test could create a fake config variable like an apitoken for Gitter/Discord/Slack.

assert_success
}

@test "$clinom config delete" {
run "${clicmd}" config delete abc
if [[ "$output" == *"Error"* ]]; then
skip "Missing varname"
fi
Copy link
Member

Choose a reason for hiding this comment

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

This test could create a fake config variable like an apitoken for Gitter/Discord/Slack.

assert_success
}

@test "$clinom config delete (non-existent user)" {
run "${clicmd}" config clear
run "${clicmd}" config delete abc
if [[ "$output" == *"Error"* ]]; then
skip "Can't delete a non-existent user"
fi
Copy link
Member

Choose a reason for hiding this comment

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

This test could assert_output --partial for the error output.

assert_success
}

@test "$clinom config clear" {
run "${clicmd}" config clear
assert_success
}