From cd4e8e0d969cdbc9ba915c2fe39ba798746d62ee Mon Sep 17 00:00:00 2001 From: kohei-kimura Date: Fri, 1 Sep 2017 22:04:09 +0900 Subject: [PATCH] add tests for pixiv.net and fix conparing strings --- command/list_test.go | 23 ++++++++++++++--------- command/search_test.go | 27 +++++++++++++++++---------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/command/list_test.go b/command/list_test.go index 0f66cfd..7980d90 100644 --- a/command/list_test.go +++ b/command/list_test.go @@ -1,7 +1,6 @@ package command import ( - "strings" "testing" ) @@ -22,9 +21,10 @@ func TestCmdList_All(t *testing.T) { | Negative Space | https://www.negativespace.co | | Magdeleine | http://magdeleine.co/ | | Picography | https://picography.co | -+----------------+------------------------------+` ++----------------+------------------------------+ +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } } @@ -42,9 +42,10 @@ https://picjumbo.com https://stocksnap.io https://www.negativespace.co http://magdeleine.co/ -https://picography.co` +https://picography.co +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } } @@ -69,9 +70,11 @@ func TestCmdList_All_Jp(t *testing.T) { | いらすとや | http://www.irasutoya.com | | マンガルー | https://www.mangaloo.jp | | ぱくたそ | https://www.pakutaso.com | -+----------------+------------------------------+` +| ピクシブ | https://www.pixiv.net | ++----------------+------------------------------+ +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } } @@ -92,9 +95,11 @@ http://magdeleine.co/ https://picography.co http://www.irasutoya.com https://www.mangaloo.jp -https://www.pakutaso.com` +https://www.pakutaso.com +https://www.pixiv.net +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } } diff --git a/command/search_test.go b/command/search_test.go index d7d53f1..a8fe933 100644 --- a/command/search_test.go +++ b/command/search_test.go @@ -37,9 +37,10 @@ func TestCmdSearch_All(t *testing.T) { | Negative Space | https://www.negativespace.co/?s=term | | Magdeleine | http://magdeleine.co/?s=term | | Picography | https://picography.co/?s=term | -+----------------+--------------------------------------+` ++----------------+--------------------------------------+ +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } } @@ -57,9 +58,10 @@ https://picjumbo.com/?s=term https://stocksnap.io/search/term https://www.negativespace.co/?s=term http://magdeleine.co/?s=term -https://picography.co/?s=term` +https://picography.co/?s=term +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } } @@ -84,9 +86,11 @@ func TestCmdSearch_All_Jp(t *testing.T) { | いらすとや | http://www.irasutoya.com/search?q=term | | マンガルー | https://www.mangaloo.jp/m/comas?coma_search_form%5Bkeyword%5D=term | | ぱくたそ | https://www.pakutaso.com/search.html?search=term | -+----------------+--------------------------------------------------------------------+` +| ピクシブ | https://www.pixiv.net/search.php?word=term | ++----------------+--------------------------------------------------------------------+ +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } } @@ -107,9 +111,11 @@ http://magdeleine.co/?s=term https://picography.co/?s=term http://www.irasutoya.com/search?q=term https://www.mangaloo.jp/m/comas?coma_search_form%5Bkeyword%5D=term -https://www.pakutaso.com/search.html?search=term` +https://www.pakutaso.com/search.html?search=term +https://www.pixiv.net/search.php?word=term +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } } @@ -141,9 +147,10 @@ func TestCmdSearch_WithSiteName(t *testing.T) { | NAME | URL | +--------------+----------------------------------+ | StockSnap.io | https://stocksnap.io/search/term | -+--------------+----------------------------------+` ++--------------+----------------------------------+ +` - if !strings.Contains(outStream.String(), expected) { + if outStream.String() != expected { t.Errorf("\nexpected: \n%s\n got: \n%s", expected, outStream.String()) } }