-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some tests and refactored the search command
- Loading branch information
Showing
4 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package commands_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pepegar/vkg-go/commands" | ||
) | ||
|
||
func TestParsePluginsList(t *testing.T) { | ||
validJson := []byte(`{ | ||
"total_results": 273, | ||
"results_per_page": 20, | ||
"total_pages": 14, | ||
"plugins": [ | ||
{ | ||
"author": "Tim Pope", | ||
"slug": "fugitive-vim", | ||
"short_desc": "fugitive.vim: a Git wrapper so awesome, it should be illegal", | ||
"github_url": "https://github.com/tpope/vim-fugitive" | ||
} | ||
] | ||
}`) | ||
|
||
response, parseError := commands.ParsePluginsList(validJson) | ||
|
||
if parseError != nil { | ||
t.Error("parsing a valid json throws an error") | ||
} | ||
|
||
if response.TotalResults != 273 { | ||
t.Error(response.TotalResults) | ||
} | ||
|
||
invalidJson := []byte(`{asdf`) | ||
|
||
_, parseErrorTwo := commands.ParsePluginsList(invalidJson) | ||
if parseErrorTwo == nil { | ||
t.Error("parsing invalid json doesn't throw an error") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters