Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maier-stefan committed May 22, 2019
1 parent 0661747 commit 5edba1c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 107 deletions.
2 changes: 1 addition & 1 deletion example/targeting_keyword_update.1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func main() {
&searchads.TargetingKeyword{
ID: targetingKeywordID,
AdGroupID: adGroupID,
MatchType: "EXACT",
MatchType: searchads.MatchTypeExact,
Status: searchads.KEYWORD_PAUSED,
Text: "test",
},
Expand Down
1 change: 0 additions & 1 deletion searchads/group_by.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
// GroupBy type to represent enum of GroupBy
type GroupBy byte

// EXACT and BROAD enum values
const (
GroupByAdminArea GroupBy = iota
GroupByAgeRange
Expand Down
54 changes: 4 additions & 50 deletions searchads/negative_keyword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestCampaignNegativeKeywordService_CreateBulk(t *testing.T) {
nk := NegativeKeyword{
CampaignID: int64(1234),
Text: "i do negative keywords",
MatchType: EXACT,
MatchType: MatchTypeExact,
Status: KEYWORD_ACTIVE,
}

Expand Down Expand Up @@ -67,7 +67,7 @@ func TestCampaignNegativeKeywordService_CreateBulk(t *testing.T) {
ID: 1,
CampaignID: 1234,
Text: "i do negative keywords",
MatchType: EXACT,
MatchType: MatchTypeExact,
Status: KEYWORD_ACTIVE,
ModificationTime: "2019-02-22T15:25:46.851",
Deleted: false,
Expand All @@ -78,29 +78,6 @@ func TestCampaignNegativeKeywordService_CreateBulk(t *testing.T) {
}
}

func TestCampaignNegativeKeywordService_Delete(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{"application/json"}
mux.HandleFunc("/campaigns/1234/negativekeywords/1234", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
w.WriteHeader(http.StatusOK)
w.Write(loadFixture("campaign_negative_keyword_delete.json"))
})

resp, err := client.CampaignNegativeKeyword.Delete(context.Background(), 1234, 1234)
if err != nil {
t.Errorf("CampaignNegativeKeyword.Delete returned error: %v", err)
}
want := http.StatusOK
got := resp.StatusCode
if !reflect.DeepEqual(got, want) {
t.Errorf("CampaignNegativeKeyword.Delete returned %+v, want %+v", got, want)
}
}

func TestAdGroupNegativeKeywordService_List(t *testing.T) {
client, mux, _, teardown := setup()
t.Log("Setup Done")
Expand Down Expand Up @@ -132,7 +109,7 @@ func TestAdGroupNegativeKeywordService_CreateBulk(t *testing.T) {
CampaignID: 1234,
AdGroupID: 1234,
Text: "i do negative keywords",
MatchType: EXACT,
MatchType: MatchTypeExact,
Status: KEYWORD_ACTIVE,
}

Expand Down Expand Up @@ -161,7 +138,7 @@ func TestAdGroupNegativeKeywordService_CreateBulk(t *testing.T) {
CampaignID: 1234,
AdGroupID: 1234,
Text: "i do negative keywords",
MatchType: EXACT,
MatchType: MatchTypeExact,
Status: KEYWORD_ACTIVE,
ModificationTime: "2019-02-22T15:25:46.851",
Deleted: false,
Expand All @@ -171,26 +148,3 @@ func TestAdGroupNegativeKeywordService_CreateBulk(t *testing.T) {
t.Errorf("AdGroupNegativeKeyword.CreateBulk returned %+v, want %+v", got, want)
}
}

func TestAdGroupNegativeKeywordService_Delete(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{"application/json"}
mux.HandleFunc("/campaigns/1234/adgroups/1234/negativekeywords/1234", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
w.WriteHeader(http.StatusOK)
w.Write(loadFixture("campaign_negative_keyword_delete.json"))
})

resp, err := client.AdGroupNegativeKeyword.Delete(context.Background(), 1234, 1234, 1234)
if err != nil {
t.Errorf("AdGroupNegativeKeyword.Delete returned error: %v", err)
}
want := http.StatusOK
got := resp.StatusCode
if !reflect.DeepEqual(got, want) {
t.Errorf("AdGroupNegativeKeyword.Delete returned %+v, want %+v", got, want)
}
}
1 change: 0 additions & 1 deletion searchads/order_by.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
// OrderBy type to represent enum of OrderBy
type OrderBy byte

// EXACT and BROAD enum values
const (
OrderByAdminArea OrderBy = iota
OrderByAgeRange
Expand Down
4 changes: 2 additions & 2 deletions searchads/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func TestReportService_SearchTerms(t *testing.T) {
metadata := SearchTermMetadata{
KeywordID: 262823190,
Keyword: "back pain",
MatchType: EXACT,
MatchType: MatchTypeExact,
BidAmount: Amount{
Amount: "12",
Currency: "EUR",
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestReportService_Keywords(t *testing.T) {
KeywordID: 262823190,
Keyword: "back pain",
KeywordStatus: KEYWORD_ACTIVE,
MatchType: EXACT,
MatchType: MatchTypeExact,
BidAmount: Amount{
Amount: "12",
Currency: "EUR",
Expand Down
54 changes: 2 additions & 52 deletions searchads/targeting_keyword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestAdGroupTargetingKeywordService_CreateBulk(t *testing.T) {
nk := TargetingKeyword{
AdGroupID: 1234,
Text: "i do negative keywords",
MatchType: EXACT,
MatchType: MatchTypeExact,
Status: KEYWORD_ACTIVE,
BidAmount: &Amount{
Amount: "1.50",
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestAdGroupTargetingKeywordService_CreateBulk(t *testing.T) {
ID: 1,
AdGroupID: 1234,
Text: "i do negative keywords",
MatchType: EXACT,
MatchType: MatchTypeExact,
Status: KEYWORD_ACTIVE,
BidAmount: &Amount{
Amount: "1.50",
Expand All @@ -84,53 +84,3 @@ func TestAdGroupTargetingKeywordService_CreateBulk(t *testing.T) {
t.Errorf("AdGroupTargetingKeyword.CreateBulk returned %+v, want %+v", got, want)
}
}

func TestAdGroupTargetingKeywordService_Delete(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{"application/json"}
mux.HandleFunc("/campaigns/1234/adgroups/1234/targetingkeywords/1234", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
w.WriteHeader(http.StatusOK)
w.Write(loadFixture("adgroup_targeting_keyword_delete.json"))
})

resp, err := client.AdGroupTargetingKeyword.Delete(context.Background(), 1234, 1234, 1234)
if err != nil {
t.Errorf("AdGroupTargetingKeyword.Delete returned error: %v", err)
}
want := http.StatusOK
got := resp.StatusCode
if !reflect.DeepEqual(got, want) {
t.Errorf("AdGroupTargetingKeyword.Delete returned %+v, want %+v", got, want)
}
}

func TestAdGroupTargetingKeywordService_Update(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{"application/json"}
mux.HandleFunc("/campaigns/1234/adgroups/1234/targetingkeywords/1234", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
w.WriteHeader(http.StatusOK)
w.Write(loadFixture("adgroup_targeting_keyword_update.json"))
})
data := &TargetingKeyword{
ID: 1234,
AdGroupID: 1234,
Status: KEYWORD_PAUSED,
}
resp, err := client.AdGroupTargetingKeyword.Update(context.Background(), 1234, 1234, 1234, data)
if err != nil {
t.Errorf("AdGroupTargetingKeyword.Update returned error: %v", err)
}
want := http.StatusOK
got := resp.StatusCode
if !reflect.DeepEqual(got, want) {
t.Errorf("AdGroupTargetingKeyword.Update returned %+v, want %+v", got, want)
}
}

0 comments on commit 5edba1c

Please sign in to comment.