Skip to content

Commit

Permalink
part of increasing test coverage above 50% (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalghost-dev committed Nov 12, 2024
1 parent e9d1521 commit 9e75584
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 5 additions & 3 deletions cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func stripANSI(input string) string {
}

func TestMainFunction(t *testing.T) {
version := "v0.6.5"
version := "v0.7.0"

// Backup the original exit function and stdout/stderr
originalExit := exit
Expand All @@ -42,6 +42,8 @@ func TestMainFunction(t *testing.T) {
args: []string{"pokemons"},
expectedOutput: "╭──────────────────────────────────────────────────────╮\n" +
"│Error! │\n" +
"│ 'pokemons' is not a valid command. │\n" +
"│ │\n" +
"│Available Commands: │\n" +
"│ pokemon Get details of a specific Pokémon │\n" +
"│ types Get details of a specific typing │\n" +
Expand All @@ -67,8 +69,8 @@ func TestMainFunction(t *testing.T) {
"│ │\n" +
"│ USAGE: │\n" +
"│ poke-cli [flag] │\n" +
"│ poke-cli [command] [flag] │\n" +
"│ poke-cli [command] [subcommand] [flag] │\n" +
"│ poke-cli <command> [flag] │\n" +
"│ poke-cli <command> <subcommand> [flag] │\n" +
"│ │\n" +
"│ FLAGS: │\n" +
"│ -h, --help Shows the help menu │\n" +
Expand Down
6 changes: 0 additions & 6 deletions flags/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ func TestLatestRelease_Success(t *testing.T) {
assert.Contains(t, output, "Latest release tag: v1.0.0")
}

func TestLatestRelease_NetworkError(t *testing.T) {
// Use an invalid URL to simulate a network error
output := captureOutput(func() { latestRelease("http://invalid-url") })
assert.Contains(t, output, "Error fetching data:")
}

func TestLatestRelease_InvalidJSON(t *testing.T) {
// Create a mock server that returns invalid JSON
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 9e75584

Please sign in to comment.