From 3fcc89920022b1fdc1d5049e66c009f7bee5bec9 Mon Sep 17 00:00:00 2001 From: Sabrina Date: Mon, 27 Jan 2020 15:28:48 -0800 Subject: [PATCH] add more unit tests --- playstore/validator_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/playstore/validator_test.go b/playstore/validator_test.go index 4fc98b4..b40ba52 100644 --- a/playstore/validator_test.go +++ b/playstore/validator_test.go @@ -42,6 +42,11 @@ func TestNew(t *testing.T) { t.Errorf("got %v\nwant %v", err, expected) } + _, actual := New(nil) + if actual == nil || actual.Error() != "unexpected end of JSON input" { + t.Errorf("got %v\nwant %v", actual, expected) + } + _, err = New(jsonKey) if err != nil { t.Errorf("got %#v", err) @@ -60,7 +65,7 @@ func TestNewWithClient(t *testing.T) { } } -func TestNewWithNoClient(t *testing.T) { +func TestNewWithClientErrors(t *testing.T) { t.Parallel() expected := errors.New("client is nil") @@ -69,6 +74,14 @@ func TestNewWithNoClient(t *testing.T) { t.Errorf("got %v\nwant %v", actual, expected) } + ctx := context.Background() + httpClient := urlfetch.Client(ctx) + + _, actual = NewWithClient(nil, httpClient) + if actual == nil || actual.Error() != "unexpected end of JSON input" { + t.Errorf("got %v\nwant %v", actual, expected) + } + } func TestAcknowledgeSubscription(t *testing.T) {