Description: disable all tests that needs network access or that work with invalid certifiicates. Author: Thorsten Alteholz Index: golang-github-sethvargo-go-fastly/fastly/acl_entries_batch_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/acl_entries_batch_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/acl_entries_batch_test.go 2019-08-22 12:58:18.573955416 +0000 @@ -1,350 +1,8 @@ package fastly import ( - "sort" "testing" ) -func TestClient_BatchModifyAclEntries_Create(t *testing.T) { - - fixtureBase := "acl_entries_batch/create/" - nameSuffix := "BatchModifyAclEntries_Create" - - // Given: a test service with an ACL and a batch of create operations, - testService := createTestService(t, fixtureBase+"create_service", nameSuffix) - defer deleteTestService(t, fixtureBase+"delete_service", testService.ID) - - testVersion := createTestVersion(t, fixtureBase+"create_version", testService.ID) - - testACL := createTestACL(t, fixtureBase+"create_acl", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestACL(t, testACL, fixtureBase+"delete_acl") - - batchCreateOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - Entries: []*BatchACLEntry{ - { - Operation: CreateBatchOperation, - IP: "127.0.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 1", - }, - { - Operation: CreateBatchOperation, - IP: "192.168.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 2", - }, - }, - } - - // When: I execute the batch create operations against the Fastly API, - var err error - record(t, fixtureBase+"create_acl_entries", func(c *Client) { - - err = c.BatchModifyACLEntries(batchCreateOperations) - }) - if err != nil { - t.Fatal(err) - } - - // Then: I expect to be able to list all of the created ACL entries. - var actualACLEntries []*ACLEntry - record(t, fixtureBase+"list_after_create", func(c *Client) { - actualACLEntries, err = c.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - sort.Slice(actualACLEntries, func(i, j int) bool { - return actualACLEntries[i].IP < actualACLEntries[j].IP - }) - - actualNumberOfACLEntries := len(actualACLEntries) - expectedNumberOfACLEntries := len(batchCreateOperations.Entries) - if actualNumberOfACLEntries != expectedNumberOfACLEntries { - t.Errorf("Incorrect number of ACL entries returned, expected: %d, got %d", expectedNumberOfACLEntries, actualNumberOfACLEntries) - } - - for i, entry := range actualACLEntries { - - actualIp := entry.IP - expectedIp := batchCreateOperations.Entries[i].IP - - if actualIp != expectedIp { - t.Errorf("IP did not match, expected %s, got %s", expectedIp, actualIp) - } - - actualSubnet := entry.Subnet - expectedSubnet := batchCreateOperations.Entries[i].Subnet - - if actualSubnet != expectedSubnet { - t.Errorf("Subnet did not match, expected %s, got %s", expectedSubnet, actualSubnet) - } - - actualNegated := entry.Negated - expectedNegated := batchCreateOperations.Entries[i].Negated - - if actualNegated != expectedNegated { - t.Errorf("Negated did not match, expected %t, got %t", expectedNegated, actualNegated) - } - - actualComment := entry.Comment - expectedComment := batchCreateOperations.Entries[i].Comment - - if actualComment != expectedComment { - t.Errorf("Comment did not match, expected %s, got %s", expectedComment, actualComment) - } - } - -} - -func TestClient_BatchModifyAclEntries_Delete(t *testing.T) { - - fixtureBase := "acl_entries_batch/delete/" - nameSuffix := "BatchModifyAclEntries_Delete" - - // Given: a test service with an ACL and a batch of create operations, - testService := createTestService(t, fixtureBase+"create_service", nameSuffix) - defer deleteTestService(t, fixtureBase+"delete_service", testService.ID) - - testVersion := createTestVersion(t, fixtureBase+"create_version", testService.ID) - - testACL := createTestACL(t, fixtureBase+"create_acl", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestACL(t, testACL, fixtureBase+"delete_acl") - - batchCreateOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - Entries: []*BatchACLEntry{ - { - Operation: CreateBatchOperation, - IP: "127.0.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 1", - }, - { - Operation: CreateBatchOperation, - IP: "192.168.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 2", - }, - }, - } - - var err error - record(t, fixtureBase+"create_acl_entries", func(c *Client) { - - err = c.BatchModifyACLEntries(batchCreateOperations) - }) - if err != nil { - t.Fatal(err) - } - - var createdACLEntries []*ACLEntry - record(t, fixtureBase+"list_before_delete", func(client *Client) { - createdACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - sort.Slice(createdACLEntries, func(i, j int) bool { - return createdACLEntries[i].IP < createdACLEntries[j].IP - }) - - // When: I execute the batch delete operations against the Fastly API, - batchDeleteOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - Entries: []*BatchACLEntry{ - { - Operation: DeleteBatchOperation, - ID: createdACLEntries[0].ID, - }, - }, - } - - record(t, fixtureBase+"delete_acl_entries", func(c *Client) { - - err = c.BatchModifyACLEntries(batchDeleteOperations) - }) - if err != nil { - t.Fatal(err) - } - - // Then: I expect to be able to list a single ACL entry. - var actualACLEntries []*ACLEntry - record(t, fixtureBase+"list_after_delete", func(client *Client) { - actualACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - sort.Slice(actualACLEntries, func(i, j int) bool { - return actualACLEntries[i].IP < actualACLEntries[j].IP - }) - - actualNumberOfACLEntries := len(actualACLEntries) - expectedNumberOfACLEntries := len(batchDeleteOperations.Entries) - if actualNumberOfACLEntries != expectedNumberOfACLEntries { - t.Errorf("Incorrect number of ACL entries returned, expected: %d, got %d", expectedNumberOfACLEntries, actualNumberOfACLEntries) - } -} - func TestClient_BatchModifyAclEntries_Update(t *testing.T) { - - fixtureBase := "acl_entries_batch/update/" - nameSuffix := "BatchModifyAclEntries_Update" - - // Given: a test service with an ACL and ACL entries, - testService := createTestService(t, fixtureBase+"create_service", nameSuffix) - defer deleteTestService(t, fixtureBase+"delete_service", testService.ID) - - testVersion := createTestVersion(t, fixtureBase+"create_version", testService.ID) - - testACL := createTestACL(t, fixtureBase+"create_acl", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestACL(t, testACL, fixtureBase+"delete_acl") - - batchCreateOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - Entries: []*BatchACLEntry{ - { - Operation: CreateBatchOperation, - IP: "127.0.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 1", - }, - { - Operation: CreateBatchOperation, - IP: "192.168.0.1", - Subnet: "24", - Negated: false, - Comment: "ACL Entry 2", - }, - }, - } - - var err error - record(t, fixtureBase+"create_acl_entries", func(c *Client) { - - err = c.BatchModifyACLEntries(batchCreateOperations) - }) - if err != nil { - t.Fatal(err) - } - - var createdACLEntries []*ACLEntry - record(t, fixtureBase+"list_before_update", func(client *Client) { - createdACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - sort.Slice(createdACLEntries, func(i, j int) bool { - return createdACLEntries[i].IP < createdACLEntries[j].IP - }) - - // When: I execute the batch update operations against the Fastly API, - batchUpdateOperations := &BatchModifyACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - Entries: []*BatchACLEntry{ - { - Operation: UpdateBatchOperation, - ID: createdACLEntries[0].ID, - IP: "127.0.0.2", - Subnet: "16", - Negated: true, - Comment: "Updated ACL Entry 1", - }, - }, - } - - record(t, fixtureBase+"update_acl_entries", func(c *Client) { - - err = c.BatchModifyACLEntries(batchUpdateOperations) - }) - if err != nil { - t.Fatal(err) - } - - // Then: I expect to be able to list all of the ACL entries with modifications applied to a single item. - var actualACLEntries []*ACLEntry - record(t, fixtureBase+"list_after_update", func(client *Client) { - actualACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - sort.Slice(actualACLEntries, func(i, j int) bool { - return actualACLEntries[i].IP < actualACLEntries[j].IP - }) - - actualNumberOfAclEntries := len(actualACLEntries) - expectedNumberOfAclEntries := len(batchCreateOperations.Entries) - if actualNumberOfAclEntries != expectedNumberOfAclEntries { - t.Errorf("Incorrect number of ACL entries returned, expected: %d, got %d", expectedNumberOfAclEntries, actualNumberOfAclEntries) - } - - actualID := actualACLEntries[0].ID - expectedID := batchUpdateOperations.Entries[0].ID - - if actualID != expectedID { - t.Errorf("First ID did not match, expected %s, got %s", expectedID, actualID) - } - - actualIP := actualACLEntries[0].IP - expectedIP := batchUpdateOperations.Entries[0].IP - - if actualIP != expectedIP { - t.Errorf("First IP did not match, expected %s, got %s", expectedIP, actualIP) - } - - actualSubnet := actualACLEntries[0].Subnet - expectedSubnet := batchUpdateOperations.Entries[0].Subnet - - if actualSubnet != expectedSubnet { - t.Errorf("First Subnet did not match, expected %s, got %s", expectedSubnet, actualSubnet) - } - - actualNegated := actualACLEntries[0].Negated - expectedNegated := batchUpdateOperations.Entries[0].Negated - - if actualNegated != expectedNegated { - t.Errorf("First Subnet did not match, expected %t, got %t", expectedNegated, actualNegated) - } - - actualComment := actualACLEntries[0].Comment - expectedComment := batchUpdateOperations.Entries[0].Comment - - if actualComment != expectedComment { - t.Errorf("First Comment did not match, expected %s, got %s", expectedComment, actualComment) - } - -} \ No newline at end of file +} Index: golang-github-sethvargo-go-fastly/fastly/acl_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/acl_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/acl_test.go 2019-08-22 12:50:43.029698989 +0000 @@ -3,111 +3,6 @@ import "testing" func TestClient_ACLs(t *testing.T) { - t.Parallel() - - fixtureBase := "acls/" - - testVersion := createTestVersion(t, fixtureBase+"version", testServiceID) - - // Create - var err error - var a *ACL - record(t, fixtureBase+"create", func(c *Client) { - a, err = c.CreateACL(&CreateACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_acl", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, fixtureBase+"cleanup", func(c *Client) { - c.DeleteACL(&DeleteACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_acl", - }) - - c.DeleteACL(&DeleteACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "new_test_acl", - }) - }) - }() - - if a.Name != "test_acl" { - t.Errorf("bad name: %q", a.Name) - } - - // List - var as []*ACL - record(t, fixtureBase+"list", func(c *Client) { - as, err = c.ListACLs(&ListACLsInput{ - Service: testServiceID, - Version: testVersion.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(as) != 1 { - t.Errorf("bad ACLs: %v", as) - } - - // Get - var na *ACL - record(t, fixtureBase+"get", func(c *Client) { - na, err = c.GetACL(&GetACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_acl", - }) - }) - if err != nil { - t.Fatal(err) - } - if a.Name != na.Name { - t.Errorf("bad name: %q (%q)", a.Name, na.Name) - } - - // Update - var ua *ACL - record(t, fixtureBase+"update", func(c *Client) { - ua, err = c.UpdateACL(&UpdateACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_acl", - NewName: "new_test_acl", - }) - }) - if err != nil { - t.Fatal(err) - } - if ua.Name != "new_test_acl" { - t.Errorf("Bad name after update %s", ua.Name) - } - - if a.ID != ua.ID { - t.Errorf("bad ACL id: %q (%q)", a.ID, ua.ID) - } - - // Delete - record(t, fixtureBase+"delete", func(c *Client) { - err = c.DeleteACL(&DeleteACLInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "new_test_acl", - }) - }) - if err != nil { - t.Fatal(err) - } - } func TestClient_ListACLs_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/dictionary_item_batch_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/dictionary_item_batch_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/dictionary_item_batch_test.go 2019-08-22 12:49:26.890313343 +0000 @@ -6,369 +6,5 @@ -func TestClient_BatchModifyDictionaryItems_Create(t *testing.T) { - - fixtureBase := "dictionary_items_batch/create/" - nameSuffix := "BatchModifyDictionaryItems_Create" - - // Given: a test service with a dictionary and a batch of create operations, - testService := createTestService(t, fixtureBase + "create_service", nameSuffix) - defer deleteTestService(t, fixtureBase +"delete_service", testService.ID) - - testVersion := createTestVersion(t,fixtureBase + "create_version", testService.ID) - - testDictionary := createTestDictionary(t, fixtureBase + "create_dictionary", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestDictionary(t, testDictionary, fixtureBase + "delete_dictionary") - - batchCreateOperations := &BatchModifyDictionaryItemsInput { - Service: testService.ID, - Dictionary: testDictionary.ID, - Items: []*BatchDictionaryItem{ - { - Operation: CreateBatchOperation, - ItemKey: "key1", - ItemValue: "val1", - }, - { - Operation: CreateBatchOperation, - ItemKey: "key2", - ItemValue: "val2", - }, - }, - } - - // When: I execute the batch create operations against the Fastly API, - var err error - record(t, fixtureBase + "create_dictionary_items", func(c *Client) { - - err = c.BatchModifyDictionaryItems(batchCreateOperations) - }) - if err != nil { - t.Fatal(err) - } - - // Then: I expect to be able to list all of the created dictionary items. - var actualDictionaryItems []*DictionaryItem - record(t, fixtureBase + "list_after_create", func(c *Client) { - actualDictionaryItems, err = c.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - actualNumberOfDictItems := len(actualDictionaryItems) - expectedNumberOfDictItems := len(batchCreateOperations.Items) - if actualNumberOfDictItems != expectedNumberOfDictItems { - t.Errorf("Incorrect number of dictionary items returned, expected: %d, got %d", expectedNumberOfDictItems, actualNumberOfDictItems) - } - - for i, item := range actualDictionaryItems { - - actualItemKey := item.ItemKey - expectedItemKey := batchCreateOperations.Items[i].ItemKey - if actualItemKey != expectedItemKey { - t.Errorf("First ItemKey did not match, expected %s, got %s", expectedItemKey, actualItemKey) - } - - actualItemValue := item.ItemValue - expectedItemValue := batchCreateOperations.Items[i].ItemValue - if actualItemValue != expectedItemValue { - t.Errorf("First ItemValue did not match, expected %s, got %s", expectedItemValue, actualItemValue) - } - - } - -} - -func TestClient_BatchModifyDictionaryItems_Delete(t *testing.T) { - - fixtureBase := "dictionary_items_batch/delete/" - nameSuffix := "BatchModifyDictionaryItems_Delete" - - // Given: a test service with a dictionary and dictionary items, - testService := createTestService(t, fixtureBase + "create_service", nameSuffix) - defer deleteTestService(t, fixtureBase + "delete_service", testService.ID) - - testVersion := createTestVersion(t,fixtureBase + "create_version", testService.ID) - - testDictionary := createTestDictionary(t, fixtureBase + "create_dictionary", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestDictionary(t, testDictionary, fixtureBase + "delete_dictionary") - - batchCreateOperations := &BatchModifyDictionaryItemsInput { - Service: testService.ID, - Dictionary: testDictionary.ID, - Items: []*BatchDictionaryItem{ - { - Operation: CreateBatchOperation, - ItemKey: "key1", - ItemValue: "val1", - }, - { - Operation: CreateBatchOperation, - ItemKey: "key2", - ItemValue: "val2", - }, - }, - } - - var err error - record(t, fixtureBase + "create_dictionary_items", func(c *Client) { - - err = c.BatchModifyDictionaryItems(batchCreateOperations) - }) - if err != nil { - t.Fatal(err) - } - - // When: I execute the batch delete operations against the Fastly API, - batchDeleteOperations := &BatchModifyDictionaryItemsInput { - Service: testService.ID, - Dictionary: testDictionary.ID, - Items: []*BatchDictionaryItem{ - { - Operation: DeleteBatchOperation, - ItemKey: "key2", - ItemValue: "val2", - }, - }, - } - - record(t, fixtureBase + "delete_dictionary_items", func(c *Client) { - - err = c.BatchModifyDictionaryItems(batchDeleteOperations) - }) - if err != nil { - t.Fatal(err) - } - - // Then: I expect to be able to list a single dictionary item. - var actualDictionaryItems []*DictionaryItem - record(t, fixtureBase + "list_after_delete", func(client *Client) { - actualDictionaryItems, err = client.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - actualNumberOfDictItems := len(actualDictionaryItems) - expectedNumberOfDictItems := len(batchDeleteOperations.Items) - if actualNumberOfDictItems != expectedNumberOfDictItems { - t.Errorf("Incorrect number of dictionary items returned, expected: %d, got %d", expectedNumberOfDictItems, actualNumberOfDictItems) - } -} - -func TestClient_BatchModifyDictionaryItems_Update(t *testing.T) { - - fixtureBase := "dictionary_items_batch/update/" - nameSuffix := "BatchModifyDictionaryItems_Update" - - // Given: a test service with a dictionary and dictionary items, - testService := createTestService(t, fixtureBase + "create_service", nameSuffix) - defer deleteTestService(t, fixtureBase + "delete_service", testService.ID) - - testVersion := createTestVersion(t,fixtureBase + "create_version", testService.ID) - - testDictionary := createTestDictionary(t, fixtureBase + "create_dictionary", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestDictionary(t, testDictionary, fixtureBase + "delete_dictionary") - - batchCreateOperations := &BatchModifyDictionaryItemsInput { - Service: testService.ID, - Dictionary: testDictionary.ID, - Items: []*BatchDictionaryItem{ - { - Operation: CreateBatchOperation, - ItemKey: "key1", - ItemValue: "val1", - }, - { - Operation: CreateBatchOperation, - ItemKey: "key2", - ItemValue: "val2", - }, - }, - } - - var err error - record(t, fixtureBase + "create_dictionary_items", func(c *Client) { - - err = c.BatchModifyDictionaryItems(batchCreateOperations) - }) - if err != nil { - t.Fatal(err) - } - - // When: I execute the batch update operations against the Fastly API, - batchUpdateOperations := &BatchModifyDictionaryItemsInput { - Service: testService.ID, - Dictionary: testDictionary.ID, - Items: []*BatchDictionaryItem{ - { - Operation: UpdateBatchOperation, - ItemKey: "key2", - ItemValue: "val2Updated", - }, - }, - } - - record(t, fixtureBase + "update_dictionary_items", func(c *Client) { - - err = c.BatchModifyDictionaryItems(batchUpdateOperations) - }) - if err != nil { - t.Fatal(err) - } - - // Then: I expect to be able to list all of the dictionary items with modifications applied to a single item. - var actualDictionaryItems []*DictionaryItem - record(t, fixtureBase + "list_after_update", func(c *Client) { - actualDictionaryItems, err = c.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - actualNumberOfDictItems := len(actualDictionaryItems) - expectedNumberOfDictItems := len(batchCreateOperations.Items) - if actualNumberOfDictItems != expectedNumberOfDictItems { - t.Errorf("Incorrect number of dictionary items returned, expected: %d, got %d", expectedNumberOfDictItems, actualNumberOfDictItems) - } - - actualItemKey := actualDictionaryItems[0].ItemKey - expectedItemKey := batchCreateOperations.Items[0].ItemKey - - if actualItemKey != expectedItemKey { - t.Errorf("First ItemKey did not match, expected %s, got %s", expectedItemKey, actualItemKey) - } - - actualItemValue := actualDictionaryItems[0].ItemValue - expectedItemValue := batchCreateOperations.Items[0].ItemValue - - - // Confirm the second dictionary item contains the modifications. - if actualItemValue != expectedItemValue { - t.Errorf("First ItemValue did not match, expected %s, got %s", expectedItemValue, actualItemValue) - } - - actualItemKey = actualDictionaryItems[1].ItemKey - expectedItemKey = batchUpdateOperations.Items[0].ItemKey - - if actualItemKey != expectedItemKey { - t.Errorf("Second ItemKey did not match, expected %s, got %s", expectedItemKey, actualItemKey) - } - - actualItemValue = actualDictionaryItems[1].ItemValue - expectedItemValue = batchUpdateOperations.Items[0].ItemValue - - - if actualItemValue != expectedItemValue { - t.Errorf("Second ItemValue did not match, expected %s, got %s", expectedItemValue, actualItemValue) - } - -} - func TestClient_BatchModifyDictionaryItems_Upsert(t *testing.T) { - - fixtureBase := "dictionary_items_batch/upsert/" - nameSuffix := "BatchModifyDictionaryItems_Upsert" - - // Given: a test service with a dictionary and dictionary items, - testService := createTestService(t, fixtureBase + "create_service", nameSuffix) - defer deleteTestService(t, fixtureBase + "delete_service", testService.ID) - - testVersion := createTestVersion(t,fixtureBase + "create_version", testService.ID) - - testDictionary := createTestDictionary(t, fixtureBase + "create_dictionary", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestDictionary(t, testDictionary, fixtureBase + "delete_dictionary") - - batchCreateOperations := &BatchModifyDictionaryItemsInput { - Service: testService.ID, - Dictionary: testDictionary.ID, - Items: []*BatchDictionaryItem{ - { - Operation: CreateBatchOperation, - ItemKey: "key1", - ItemValue: "val1", - }, - }, - } - - var err error - record(t, fixtureBase + "create_dictionary_items", func(c *Client) { - - err = c.BatchModifyDictionaryItems(batchCreateOperations) - }) - if err != nil { - t.Fatal(err) - } - - // When: I execute the batch upsert operations against the Fastly API - batchUpsertOperations := &BatchModifyDictionaryItemsInput { - Service: testService.ID, - Dictionary: testDictionary.ID, - Items: []*BatchDictionaryItem{ - { - Operation: UpsertBatchOperation, - ItemKey: "key1", - ItemValue: "val1Updated", - }, - { - Operation: UpsertBatchOperation, - ItemKey: "key2", - ItemValue: "val2", - }, - }, - } - - record(t, fixtureBase + "upsert_dictionary_items", func(c *Client) { - - err = c.BatchModifyDictionaryItems(batchUpsertOperations) - }) - if err != nil { - t.Fatal(err) - } - - - // Then: I expect to be able to list all of the dictionary items with the modification present. - var actualDictionaryItems []*DictionaryItem - record(t, fixtureBase + "list_after_upsert", func(c *Client) { - actualDictionaryItems, err = c.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - actualNumberOfDictItems := len(actualDictionaryItems) - expectedNumberOfDictItems := len(batchUpsertOperations.Items) - if actualNumberOfDictItems != expectedNumberOfDictItems { - t.Errorf("Incorrect number of dictionary items returned, expected: %d, got %d", expectedNumberOfDictItems, actualNumberOfDictItems) - } - - for i, item := range actualDictionaryItems { - - actualItemKey := item.ItemKey - expectedItemKey := batchUpsertOperations.Items[i].ItemKey - if actualItemKey != expectedItemKey { - t.Errorf("First ItemKey did not match, expected %s, got %s", expectedItemKey, actualItemKey) - } - - actualItemValue := item.ItemValue - expectedItemValue := batchUpsertOperations.Items[i].ItemValue - if actualItemValue != expectedItemValue { - t.Errorf("First ItemValue did not match, expected %s, got %s", expectedItemValue, actualItemValue) - } - - } - -} \ No newline at end of file +} Index: golang-github-sethvargo-go-fastly/fastly/papertrail_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/papertrail_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/papertrail_test.go 2019-08-22 12:51:13.515054559 +0000 @@ -3,142 +3,6 @@ import "testing" func TestClient_Papertrails(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "papertrails/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var p *Papertrail - record(t, "papertrails/create", func(c *Client) { - p, err = c.CreatePapertrail(&CreatePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-papertrail", - Address: "integ-test.go-fastly.com", - Port: 1234, - FormatVersion: 2, - Format: "format", - Placement: "waf_debug", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "papertrails/cleanup", func(c *Client) { - c.DeletePapertrail(&DeletePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-papertrail", - }) - - c.DeletePapertrail(&DeletePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-papertrail", - }) - }) - }() - - if p.Name != "test-papertrail" { - t.Errorf("bad name: %q", p.Name) - } - if p.Address != "integ-test.go-fastly.com" { - t.Errorf("bad address: %q", p.Address) - } - if p.Port != 1234 { - t.Errorf("bad port: %q", p.Port) - } - if p.FormatVersion != 2 { - t.Errorf("bad format_version: %q", p.FormatVersion) - } - if p.Format != "format" { - t.Errorf("bad format: %q", p.Format) - } - if p.Placement != "waf_debug" { - t.Errorf("bad placement: %q", p.Placement) - } - - // List - var ps []*Papertrail - record(t, "papertrails/list", func(c *Client) { - ps, err = c.ListPapertrails(&ListPapertrailsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ps) < 1 { - t.Errorf("bad papertrails: %v", ps) - } - - // Get - var np *Papertrail - record(t, "papertrails/get", func(c *Client) { - np, err = c.GetPapertrail(&GetPapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-papertrail", - }) - }) - if err != nil { - t.Fatal(err) - } - if p.Name != np.Name { - t.Errorf("bad name: %q", p.Name) - } - if p.Address != np.Address { - t.Errorf("bad address: %q", p.Address) - } - if p.Port != np.Port { - t.Errorf("bad port: %q", p.Port) - } - if p.FormatVersion != np.FormatVersion { - t.Errorf("bad format_version: %q", p.FormatVersion) - } - if p.Format != np.Format { - t.Errorf("bad format: %q", p.Format) - } - if p.Placement != np.Placement { - t.Errorf("bad placement: %q", p.Placement) - } - - // Update - var up *Papertrail - record(t, "papertrails/update", func(c *Client) { - up, err = c.UpdatePapertrail(&UpdatePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-papertrail", - NewName: "new-test-papertrail", - }) - }) - if err != nil { - t.Fatal(err) - } - if up.Name != "new-test-papertrail" { - t.Errorf("bad name: %q", up.Name) - } - - // Delete - record(t, "papertrails/delete", func(c *Client) { - err = c.DeletePapertrail(&DeletePapertrailInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-papertrail", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListPapertrails_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/version_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/version_test.go 2019-08-21 23:08:10.893972822 +0000 +++ golang-github-sethvargo-go-fastly/fastly/version_test.go 2019-08-22 12:52:34.346648850 +0000 @@ -6,114 +6,6 @@ ) func TestClient_Versions(t *testing.T) { - t.Parallel() - - var err error - - // Lock because we are creating a new version. - testVersionLock.Lock() - - // Create - var v *Version - record(t, "versions/create", func(c *Client) { - v, err = c.CreateVersion(&CreateVersionInput{ - Service: testServiceID, - Comment: "test comment", - }) - }) - if err != nil { - t.Fatal(err) - } - if v.Number == 0 { - t.Errorf("bad number: %q", v.Number) - } - if v.Comment != "test comment" { - t.Errorf("bad comment: %q", v.Comment) - } - - // Unlock and let other parallel tests go! - testVersionLock.Unlock() - - // List - var vs []*Version - record(t, "versions/list", func(c *Client) { - vs, err = c.ListVersions(&ListVersionsInput{ - Service: testServiceID, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(vs) < 1 { - t.Errorf("bad services: %v", vs) - } - - // Get - var nv *Version - record(t, "versions/get", func(c *Client) { - nv, err = c.GetVersion(&GetVersionInput{ - Service: testServiceID, - Version: v.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if nv.Number == 0 { - t.Errorf("bad number: %q", nv.Number) - } - if nv.Comment != v.Comment { - t.Errorf("bad comment: %q", v.Comment) - } - - // Update - var uv *Version - record(t, "versions/update", func(c *Client) { - uv, err = c.UpdateVersion(&UpdateVersionInput{ - Service: testServiceID, - Version: v.Number, - Comment: "new comment", - }) - }) - if err != nil { - t.Fatal(err) - } - if uv.Comment != "new comment" { - t.Errorf("bad comment: %q", uv.Comment) - } - - // Lock - var vl *Version - record(t, "versions/lock", func(c *Client) { - vl, err = c.LockVersion(&LockVersionInput{ - Service: testServiceID, - Version: v.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if vl.Locked != true { - t.Errorf("bad lock: %t", vl.Locked) - } - - // Clone - var cv *Version - record(t, "versions/clone", func(c *Client) { - cv, err = c.CloneVersion(&CloneVersionInput{ - Service: testServiceID, - Version: v.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if cv.Active != false { - t.Errorf("bad clone: %t", cv.Active) - } - if cv.Comment != uv.Comment { - t.Errorf("bad comment: %q", uv.Comment) - } } func TestClient_SortVersions(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/waf_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/waf_test.go 2019-08-21 23:08:10.893972822 +0000 +++ golang-github-sethvargo-go-fastly/fastly/waf_test.go 2019-08-22 12:51:57.124993747 +0000 @@ -7,204 +7,6 @@ ) func TestClient_WAFs(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "wafs/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Enable logging on the service - we cannot create wafs without logging - // enabled - record(t, "wafs/logging/create", func(c *Client) { - _, err = c.CreateSyslog(&CreateSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", - Address: "example.com", - Hostname: "example.com", - Port: 1234, - Token: "abcd1234", - Format: "format", - FormatVersion: 2, - MessageType: "classic", - }) - }) - if err != nil { - t.Fatal(err) - } - defer func() { - record(t, "wafs/logging/cleanup", func(c *Client) { - c.DeleteSyslog(&DeleteSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", - }) - }) - }() - - // Create a condition - we cannot create a waf without attaching a condition - var condition *Condition - record(t, "wafs/condition/create", func(c *Client) { - condition, err = c.CreateCondition(&CreateConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-waf-condition", - Statement: "req.url~+\"index.html\"", - Type: "PREFETCH", // This must be a prefetch condition - Priority: 1, - }) - }) - if err != nil { - t.Fatal(err) - } - defer func() { - record(t, "wafs/condition/cleanup", func(c *Client) { - c.DeleteCondition(&DeleteConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-waf-condition", - }) - }) - }() - - // Create a response object - var ro *ResponseObject - record(t, "wafs/response_object/create", func(c *Client) { - ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", - Status: 200, - Response: "Ok", - Content: "abcd", - ContentType: "text/plain", - }) - }) - if err != nil { - t.Fatal(err) - } - defer func() { - record(t, "wafs/response_object/cleanup", func(c *Client) { - c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: ro.Name, - }) - }) - }() - - // Create - var waf *WAF - record(t, "wafs/create", func(c *Client) { - waf, err = c.CreateWAF(&CreateWAFInput{ - Service: testServiceID, - Version: tv.Number, - PrefetchCondition: condition.Name, - Response: ro.Name, - }) - }) - if err != nil { - t.Fatal(err) - } - - // List - var wafs []*WAF - record(t, "wafs/list", func(c *Client) { - wafs, err = c.ListWAFs(&ListWAFsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(wafs) < 1 { - t.Errorf("bad wafs: %v", wafs) - } - - // Ensure deleted - defer func() { - record(t, "wafs/cleanup", func(c *Client) { - c.DeleteWAF(&DeleteWAFInput{ - Service: testServiceID, - Version: tv.Number, - ID: waf.ID, - }) - }) - }() - - // Get - var nwaf *WAF - record(t, "wafs/get", func(c *Client) { - nwaf, err = c.GetWAF(&GetWAFInput{ - Service: testServiceID, - Version: tv.Number, - ID: waf.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - if nwaf.ID != waf.ID { - t.Errorf("expected %q to be %q", nwaf.ID, waf.ID) - } - - // Update - // Create a new response object to attach - var nro *ResponseObject - record(t, "wafs/response_object/create_another", func(c *Client) { - nro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object-2", - Status: 200, - Response: "Ok", - Content: "efgh", - ContentType: "text/plain", - }) - }) - if err != nil { - t.Fatal(err) - } - defer func() { - record(t, "wafs/response_object/cleanup_another", func(c *Client) { - c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: nro.Name, - }) - }) - }() - var uwaf *WAF - record(t, "wafs/update", func(c *Client) { - uwaf, err = c.UpdateWAF(&UpdateWAFInput{ - Service: testServiceID, - Version: tv.Number, - ID: waf.ID, - Response: nro.Name, - }) - }) - if err != nil { - t.Fatal(err) - } - if uwaf.Response != "test-response-object-2" { - t.Errorf("bad name: %q", uwaf.Response) - } - - // Delete - record(t, "wafs/delete", func(c *Client) { - err = c.DeleteWAF(&DeleteWAFInput{ - Service: testServiceID, - Version: tv.Number, - ID: waf.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - } func TestClient_ListWAFs_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/acl_entry_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/acl_entry_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/acl_entry_test.go 2019-08-22 13:03:55.416933587 +0000 @@ -3,135 +3,6 @@ import "testing" func TestClient_ACLEntries(t *testing.T) { - - fixtureBase := "acl_entries/" - nameSuffix := "ACLEntries" - - testService := createTestService(t, fixtureBase+"create_service", nameSuffix) - defer deleteTestService(t, fixtureBase+"delete_service", testService.ID) - - testVersion := createTestVersion(t, fixtureBase+"version", testService.ID) - - testACL := createTestACL(t, fixtureBase+"acl", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestACL(t, testACL, fixtureBase+"delete_acl") - - // Create - var err error - var e *ACLEntry - record(t, fixtureBase+"create", func(c *Client) { - e, err = c.CreateACLEntry(&CreateACLEntryInput{ - Service: testService.ID, - ACL: testACL.ID, - IP: "10.0.0.3", - Subnet: "8", - Negated: false, - Comment: "test entry", - }) - }) - if err != nil { - t.Fatal(err) - } - - if e.IP != "10.0.0.3" { - t.Errorf("bad IP: %q", e.IP) - } - - if e.Subnet != "8" { - t.Errorf("Bad subnet: %q", e.Subnet) - } - - if e.Negated != false { - t.Errorf("Bad negated flag: %t", e.Negated) - } - - if e.Comment != "test entry" { - t.Errorf("Bad comment: %q", e.Comment) - } - - // List - var es []*ACLEntry - record(t, fixtureBase+"list", func(c *Client) { - es, err = c.ListACLEntries(&ListACLEntriesInput{ - Service: testService.ID, - ACL: testACL.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - if len(es) != 1 { - t.Errorf("Bad entries: %v", es) - } - - // Get - var ne *ACLEntry - record(t, fixtureBase+"get", func(c *Client) { - ne, err = c.GetACLEntry(&GetACLEntryInput{ - Service: testService.ID, - ACL: testACL.ID, - ID: e.ID, - }) - }) - - if e.IP != ne.IP { - t.Errorf("bad IP: %v", ne.IP) - } - - if e.Subnet != ne.Subnet { - t.Errorf("bad subnet: %v", ne.Subnet) - } - - if e.Negated != ne.Negated { - t.Errorf("bad Negated flag: %v", ne.Negated) - } - - if e.Comment != ne.Comment { - t.Errorf("bad comment: %v", ne.Comment) - } - - // Update - var ue *ACLEntry - record(t, fixtureBase+"update", func(c *Client) { - ue, err = c.UpdateACLEntry(&UpdateACLEntryInput{ - Service: testService.ID, - ACL: testACL.ID, - ID: e.ID, - IP: "10.0.0.4", - Negated: true, - }) - }) - if err != nil { - t.Fatal(err) - } - - if ue.IP != "10.0.0.4" { - t.Errorf("bad IP: %q", ue.IP) - } - if e.Subnet != ue.Subnet { - t.Errorf("bad subnet: %v", ne.Subnet) - } - - if ue.Negated != true { - t.Errorf("bad Negated flag: %v", ne.Negated) - } - - if e.Comment != ue.Comment { - t.Errorf("bad comment: %v", ne.Comment) - } - - // Delete - record(t, fixtureBase+"delete", func(c *Client) { - err = c.DeleteACLEntry(&DeleteACLEntryInput{ - Service: testService.ID, - ACL: testACL.ID, - ID: e.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - } func TestClient_ListACLEntries_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/backend_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/backend_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/backend_test.go 2019-08-22 13:05:21.388756445 +0000 @@ -3,139 +3,6 @@ import "testing" func TestClient_Backends(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "backends/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var b *Backend - record(t, "backends/create", func(c *Client) { - b, err = c.CreateBackend(&CreateBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-backend", - Address: "integ-test.go-fastly.com", - Port: 1234, - ConnectTimeout: 1500, - OverrideHost: "origin.example.com", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "backends/cleanup", func(c *Client) { - c.DeleteBackend(&DeleteBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-backend", - }) - - c.DeleteBackend(&DeleteBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-backend", - }) - }) - }() - - if b.Name != "test-backend" { - t.Errorf("bad name: %q", b.Name) - } - if b.Address != "integ-test.go-fastly.com" { - t.Errorf("bad address: %q", b.Address) - } - if b.Port != 1234 { - t.Errorf("bad port: %d", b.Port) - } - if b.ConnectTimeout != 1500 { - t.Errorf("bad connect_timeout: %d", b.ConnectTimeout) - } - if b.OverrideHost != "origin.example.com" { - t.Errorf("bad override_host: %q", b.OverrideHost) - } - - // List - var bs []*Backend - record(t, "backends/list", func(c *Client) { - bs, err = c.ListBackends(&ListBackendsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(bs) < 1 { - t.Errorf("bad backends: %v", bs) - } - - // Get - var nb *Backend - record(t, "backends/get", func(c *Client) { - nb, err = c.GetBackend(&GetBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-backend", - }) - }) - if err != nil { - t.Fatal(err) - } - if b.Name != nb.Name { - t.Errorf("bad name: %q (%q)", b.Name, nb.Name) - } - if b.Address != nb.Address { - t.Errorf("bad address: %q (%q)", b.Address, nb.Address) - } - if b.Port != nb.Port { - t.Errorf("bad port: %q (%q)", b.Port, nb.Port) - } - if b.ConnectTimeout != nb.ConnectTimeout { - t.Errorf("bad connect_timeout: %q (%q)", b.ConnectTimeout, nb.ConnectTimeout) - } - if b.OverrideHost != nb.OverrideHost { - t.Errorf("bad override_host: %q (%q)", b.OverrideHost, nb.OverrideHost) - } - - // Update - var ub *Backend - record(t, "backends/update", func(c *Client) { - ub, err = c.UpdateBackend(&UpdateBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-backend", - NewName: "new-test-backend", - OverrideHost: "www.example.com", - }) - }) - if err != nil { - t.Fatal(err) - } - if ub.Name != "new-test-backend" { - t.Errorf("bad name: %q", ub.Name) - } - if ub.OverrideHost != "www.example.com" { - t.Errorf("bad override_host: %q", ub.OverrideHost) - } - - // Delete - record(t, "backends/delete", func(c *Client) { - err = c.DeleteBackend(&DeleteBackendInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-backend", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListBackends_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/dictionary_item_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/dictionary_item_test.go 2019-08-21 23:08:10.833970154 +0000 +++ golang-github-sethvargo-go-fastly/fastly/dictionary_item_test.go 2019-08-22 13:04:41.430979666 +0000 @@ -3,113 +3,6 @@ import "testing" func TestClient_DictionaryItems(t *testing.T) { - - fixtureBase := "dictionary_items/" - nameSuffix := "DictionaryItems" - - testService := createTestService(t, fixtureBase + "create_service", nameSuffix) - defer deleteTestService(t, fixtureBase +"delete_service", testService.ID) - - testVersion := createTestVersion(t, fixtureBase+"version", testService.ID) - - testDictionary := createTestDictionary(t, fixtureBase+"dictionary", testService.ID, testVersion.Number, nameSuffix) - defer deleteTestDictionary(t, testDictionary, fixtureBase+"delete_dictionary") - - // Create - var err error - var createdDictionaryItem *DictionaryItem - record(t, fixtureBase+"create", func(c *Client) { - createdDictionaryItem, err = c.CreateDictionaryItem(&CreateDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", - ItemValue: "value", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, fixtureBase+"cleanup", func(c *Client) { - c.DeleteDictionaryItem(&DeleteDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", - }) - }) - }() - - if createdDictionaryItem.ItemKey != "test-dictionary-item" { - t.Errorf("bad item_key: %q", createdDictionaryItem.ItemKey) - } - if createdDictionaryItem.ItemValue != "value" { - t.Errorf("bad item_value: %q", createdDictionaryItem.ItemValue) - } - - // List - var dictionaryItems []*DictionaryItem - record(t, fixtureBase+"list", func(c *Client) { - dictionaryItems, err = c.ListDictionaryItems(&ListDictionaryItemsInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(dictionaryItems) < 1 { - t.Errorf("bad dictionary items: %v", dictionaryItems) - } - - // Get - var retrievedDictionaryItem *DictionaryItem - record(t, fixtureBase+"get", func(c *Client) { - retrievedDictionaryItem, err = c.GetDictionaryItem(&GetDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", - }) - }) - if err != nil { - t.Fatal(err) - } - if retrievedDictionaryItem.ItemKey != "test-dictionary-item" { - t.Errorf("bad item_key: %q", retrievedDictionaryItem.ItemKey) - } - if retrievedDictionaryItem.ItemValue != "value" { - t.Errorf("bad item_value: %q", retrievedDictionaryItem.ItemValue) - } - - // Update - var updatedDictionaryItem *DictionaryItem - record(t, fixtureBase+"update", func(c *Client) { - updatedDictionaryItem, err = c.UpdateDictionaryItem(&UpdateDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", - ItemValue: "new-value", - }) - }) - if err != nil { - t.Fatal(err) - } - if updatedDictionaryItem.ItemValue != "new-value" { - t.Errorf("bad item_value: %q", updatedDictionaryItem.ItemValue) - } - - // Delete - record(t, fixtureBase+"delete", func(c *Client) { - err = c.DeleteDictionaryItem(&DeleteDictionaryItemInput{ - Service: testService.ID, - Dictionary: testDictionary.ID, - ItemKey: "test-dictionary-item", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListDictionaryItems_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/stats_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/stats_test.go 2019-08-21 23:08:10.893972822 +0000 +++ golang-github-sethvargo-go-fastly/fastly/stats_test.go 2019-08-22 13:10:13.977766825 +0000 @@ -3,66 +3,13 @@ import "testing" func TestClient_GetStats(t *testing.T) { - t.Parallel() - - var err error - record(t, "stats/service_stats", func(c *Client) { - _, err = c.GetStats(&GetStatsInput{ - Service: testServiceID, - From: "10 days ago", - To: "now", - By: "minute", - Region: "europe", - }) - }) - if err != nil { - t.Fatal(err) - } - } func TestClient_GetRegions(t *testing.T) { - t.Parallel() - - var err error - record(t, "stats/regions", func(c *Client) { - _, err = c.GetRegions() - }) - if err != nil { - t.Fatal(err) - } } func TestClient_GetRegionsUsage(t *testing.T) { - t.Parallel() - - var err error - record(t, "stats/regions_usage", func(c *Client) { - _, err = c.GetUsage(&GetUsageInput{ - From: "10 days ago", - To: "now", - By: "minute", - Region: "usa", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_GetServicesByRegionsUsage(t *testing.T) { - t.Parallel() - - var err error - record(t, "stats/services_usage", func(c *Client) { - _, err = c.GetUsageByService(&GetUsageInput{ - From: "10 days ago", - To: "now", - By: "minute", - Region: "usa", - }) - }) - if err != nil { - t.Fatal(err) - } } Index: golang-github-sethvargo-go-fastly/fastly/sumologic_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/sumologic_test.go 2019-08-21 23:08:10.893972822 +0000 +++ golang-github-sethvargo-go-fastly/fastly/sumologic_test.go 2019-08-22 13:10:53.111506958 +0000 @@ -3,142 +3,6 @@ import "testing" func TestClient_Sumologics(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "sumologics/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var s *Sumologic - record(t, "sumologics/create", func(c *Client) { - s, err = c.CreateSumologic(&CreateSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sumologic", - URL: "https://foo.sumologic.com", - Format: "format", - FormatVersion: 1, - MessageType: "classic", - Placement: "waf_debug", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "sumologics/cleanup", func(c *Client) { - c.DeleteSumologic(&DeleteSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sumologic", - }) - - c.DeleteSumologic(&DeleteSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-sumologic", - }) - }) - }() - - if s.Name != "test-sumologic" { - t.Errorf("bad name: %q", s.Name) - } - if s.URL != "https://foo.sumologic.com" { - t.Errorf("bad url: %q", s.URL) - } - if s.Format != "format" { - t.Errorf("bad format: %q", s.Format) - } - if s.FormatVersion != 1 { - t.Errorf("bad format version: %q", s.FormatVersion) - } - if s.MessageType != "classic" { - t.Errorf("bad message type: %q", s.MessageType) - } - if s.Placement != "waf_debug" { - t.Errorf("bad placement: %q", s.Placement) - } - - // List - var ss []*Sumologic - record(t, "sumologics/list", func(c *Client) { - ss, err = c.ListSumologics(&ListSumologicsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ss) < 1 { - t.Errorf("bad sumologics: %v", ss) - } - - // Get - var ns *Sumologic - record(t, "sumologics/get", func(c *Client) { - ns, err = c.GetSumologic(&GetSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sumologic", - }) - }) - if err != nil { - t.Fatal(err) - } - if s.Name != ns.Name { - t.Errorf("bad name: %q", s.Name) - } - if s.URL != ns.URL { - t.Errorf("bad url: %q", s.URL) - } - if s.Format != ns.Format { - t.Errorf("bad format: %q", s.Format) - } - if s.FormatVersion != ns.FormatVersion { - t.Errorf("bad format version: %q", s.FormatVersion) - } - if s.MessageType != ns.MessageType { - t.Errorf("bad message type: %q", s.MessageType) - } - if s.Placement != ns.Placement { - t.Errorf("bad placement: %q", s.Placement) - } - - // Update - var us *Sumologic - record(t, "sumologics/update", func(c *Client) { - us, err = c.UpdateSumologic(&UpdateSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-sumologic", - NewName: "new-test-sumologic", - }) - }) - if err != nil { - t.Fatal(err) - } - if us.Name != "new-test-sumologic" { - t.Errorf("bad name: %q", us.Name) - } - - // Delete - record(t, "sumologics/delete", func(c *Client) { - err = c.DeleteSumologic(&DeleteSumologicInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-sumologic", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListSumologics_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/syslog_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/syslog_test.go 2019-08-21 23:08:10.893972822 +0000 +++ golang-github-sethvargo-go-fastly/fastly/syslog_test.go 2019-08-22 13:19:25.602295582 +0000 @@ -1,212 +1,10 @@ package fastly import ( - "strings" "testing" ) func TestClient_Syslogs(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "syslogs/version", func(c *Client) { - tv = testVersion(t, c) - }) - - cert := strings.TrimSpace(` ------BEGIN CERTIFICATE----- -MIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL -MAkGA1UECBMCUE4xCzAJBgNVBAcTAkNOMQswCQYDVQQKEwJPTjELMAkGA1UECxMC -VU4xFDASBgNVBAMTC0hlcm9uZyBZYW5nMB4XDTA1MDcxNTIxMTk0N1oXDTA1MDgx -NDIxMTk0N1owVzELMAkGA1UEBhMCQ04xCzAJBgNVBAgTAlBOMQswCQYDVQQHEwJD -TjELMAkGA1UEChMCT04xCzAJBgNVBAsTAlVOMRQwEgYDVQQDEwtIZXJvbmcgWWFu -ZzBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCp5hnG7ogBhtlynpOS21cBewKE/B7j -V14qeyslnr26xZUsSVko36ZnhiaO/zbMOoRcKK9vEcgMtcLFuQTWDl3RAgMBAAGj -gbEwga4wHQYDVR0OBBYEFFXI70krXeQDxZgbaCQoR4jUDncEMH8GA1UdIwR4MHaA -FFXI70krXeQDxZgbaCQoR4jUDncEoVukWTBXMQswCQYDVQQGEwJDTjELMAkGA1UE -CBMCUE4xCzAJBgNVBAcTAkNOMQswCQYDVQQKEwJPTjELMAkGA1UECxMCVU4xFDAS -BgNVBAMTC0hlcm9uZyBZYW5nggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEE -BQADQQA/ugzBrjjK9jcWnDVfGHlk3icNRq0oV7Ri32z/+HQX67aRfgZu7KWdI+Ju -Wm7DCfrPNGVwFWUQOmsPue9rZBgO ------END CERTIFICATE----- -`) - - // Create - var s *Syslog - record(t, "syslogs/create", func(c *Client) { - s, err = c.CreateSyslog(&CreateSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", - Address: "example.com", - Hostname: "example.com", - Port: 1234, - UseTLS: CBool(true), - TLSCACert: cert, - TLSHostname: "example.com", - Token: "abcd1234", - Format: "format", - FormatVersion: 2, - MessageType: "classic", - Placement: "waf_debug", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "syslogs/cleanup", func(c *Client) { - c.DeleteSyslog(&DeleteSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", - }) - - c.DeleteSyslog(&DeleteSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-syslog", - }) - }) - }() - - if s.Name != "test-syslog" { - t.Errorf("bad name: %q", s.Name) - } - if s.Address != "example.com" { - t.Errorf("bad address: %q", s.Address) - } - if s.Hostname != "example.com" { - t.Errorf("bad hostname: %q", s.Hostname) - } - if s.Port != 1234 { - t.Errorf("bad port: %q", s.Port) - } - if s.UseTLS != true { - t.Errorf("bad use_tls: %t", s.UseTLS) - } - if s.TLSCACert != cert { - t.Errorf("bad tls_ca_cert: %q", s.TLSCACert) - } - if s.TLSHostname != "example.com" { - t.Errorf("bad tls_hostname: %q", s.TLSHostname) - } - if s.Token != "abcd1234" { - t.Errorf("bad token: %q", s.Token) - } - if s.Format != "format" { - t.Errorf("bad format: %q", s.Format) - } - if s.FormatVersion != 2 { - t.Errorf("bad format_version: %d", s.FormatVersion) - } - if s.MessageType != "classic" { - t.Errorf("bad message_type: %s", s.MessageType) - } - if s.Placement != "waf_debug" { - t.Errorf("bad placement: %q", s.Placement) - } - - // List - var ss []*Syslog - record(t, "syslogs/list", func(c *Client) { - ss, err = c.ListSyslogs(&ListSyslogsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ss) < 1 { - t.Errorf("bad syslogs: %v", ss) - } - - // Get - var ns *Syslog - record(t, "syslogs/get", func(c *Client) { - ns, err = c.GetSyslog(&GetSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", - }) - }) - if err != nil { - t.Fatal(err) - } - if s.Name != ns.Name { - t.Errorf("bad name: %q", s.Name) - } - if s.Address != ns.Address { - t.Errorf("bad address: %q", s.Address) - } - if s.Hostname != ns.Hostname { - t.Errorf("bad hostname: %q", s.Hostname) - } - if s.Port != ns.Port { - t.Errorf("bad port: %q", s.Port) - } - if s.UseTLS != ns.UseTLS { - t.Errorf("bad use_tls: %t", s.UseTLS) - } - if s.TLSCACert != ns.TLSCACert { - t.Errorf("bad tls_ca_cert: %q", s.TLSCACert) - } - if s.TLSHostname != ns.TLSHostname { - t.Errorf("bad tls_hostname: %q", s.TLSHostname) - } - if s.Token != ns.Token { - t.Errorf("bad token: %q", s.Token) - } - if s.Format != ns.Format { - t.Errorf("bad format: %q", s.Format) - } - if s.FormatVersion != ns.FormatVersion { - t.Errorf("bad format_version: %q", s.FormatVersion) - } - if s.MessageType != ns.MessageType { - t.Errorf("bad message_type: %q", s.MessageType) - } - if s.Placement != ns.Placement { - t.Errorf("bad placement: %q", s.Placement) - } - - // Update - var us *Syslog - record(t, "syslogs/update", func(c *Client) { - us, err = c.UpdateSyslog(&UpdateSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-syslog", - NewName: "new-test-syslog", - FormatVersion: 2, - }) - }) - if err != nil { - t.Fatal(err) - } - if us.Name != "new-test-syslog" { - t.Errorf("bad name: %q", us.Name) - } - - if us.FormatVersion != 2 { - t.Errorf("bad format_version: %d", us.FormatVersion) - } - - // Delete - record(t, "syslogs/delete", func(c *Client) { - err = c.DeleteSyslog(&DeleteSyslogInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-syslog", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListSyslogs_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/vcl_snippets_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/vcl_snippets_test.go 2019-08-21 23:08:10.893972822 +0000 +++ golang-github-sethvargo-go-fastly/fastly/vcl_snippets_test.go 2019-08-22 13:08:29.349114373 +0000 @@ -3,258 +3,4 @@ import "testing" func Test_Snippets(t *testing.T) { - t.Parallel() - - const ( - testDynSnippetName = "testsnip5" - testSnippetName = "testsnip0" - ) - - var err error - var tv *Version - record(t, "vcl_snippets/version", func(c *Client) { - tv = testVersion(t, c) - }) - - content := ` - # testing EdgeACL2 and EdgeDictionary2 - declare local var.number2 STRING; - set var.number2 = table.lookup(demoDICTtest, client.as.number); - - if (var.number2 == "true") { - set req.http.securityruleid = "num2-block"; - error 403 "Access Denied"; - } - ` - - dynContent := ` - # testing EdgeACL6 and EdgeDictionary6 - declare local var.number6 STRING; - set var.number6 = table.lookup(demoDICTtest, client.as.number); - - if (var.number6 == "true") { - set req.http.securityruleid = "num6-block"; - error 403 "Access Denied"; - } - ` - updatedDynContent := ` - # testing EdgeACL5 and EdgeDictionary5 - declare local var.number5 STRING; - set var.number5 = table.lookup(demoDICTtest, client.as.number); - - if (var.number5 == "true") { - set req.http.securityruleid = "num5-block"; - error 403 "Access Denied"; - } - ` - - // Create - var cs *Snippet - record(t, "vcl_snippets/create", func(c *Client) { - cs, err = c.CreateSnippet(&CreateSnippetInput{ - Service: testServiceID, - Version: tv.Number, - Name: testSnippetName, - Type: SnippetTypeRecv, - Priority: 100, - Dynamic: 0, - Content: content, - }) - }) - - if err != nil { - t.Fatal(err) - } - if cs.ServiceID != testServiceID { - t.Errorf("bad sID: %q", cs.ServiceID) - } - if cs.Name != testSnippetName { - t.Errorf("bad name: %q", cs.Name) - } - if cs.Type != SnippetTypeRecv { - t.Errorf("bad type: %q", cs.Type) - } - if cs.Content != content { - t.Errorf("bad content: %q", cs.Content) - } - - // Create Dynamic - var cds *Snippet - record(t, "vcl_snippets/create_dyn", func(c *Client) { - cds, err = c.CreateSnippet(&CreateSnippetInput{ - Service: testServiceID, - Version: tv.Number, - Name: testDynSnippetName, - Type: SnippetTypeRecv, - Priority: 100, - Dynamic: 1, - Content: dynContent, - }) - }) - - if err != nil { - t.Fatal(err) - } - if cds.ServiceID != testServiceID { - t.Errorf("bad sID: %q", cds.ServiceID) - } - if cds.Name != testDynSnippetName { - t.Errorf("bad name: %q", cds.Name) - } - if cds.Type != SnippetTypeRecv { - t.Errorf("bad type: %q", cds.Type) - } - - // Update Dynamic - var uds *DynamicSnippet - record(t, "vcl_snippets/update_dyn", func(c *Client) { - uds, err = c.UpdateDynamicSnippet(&UpdateDynamicSnippetInput{ - Service: testServiceID, - ID: cds.ID, - Content: updatedDynContent, - }) - }) - if err != nil { - t.Fatal(err) - } - - if uds.Content != updatedDynContent { - t.Errorf("bad content: %q", uds.Content) - } - - // Delete - record(t, "vcl_snippets/delete", func(c *Client) { - err = c.DeleteSnippet(&DeleteSnippetInput{ - Service: testServiceID, - Name: testDynSnippetName, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - - // GETDynamicSnippet - var ds *DynamicSnippet - record(t, "vcl_snippets/get_dynamic", func(c *Client) { - ds, err = c.GetDynamicSnippet(&GetDynamicSnippetInput{ - Service: testServiceID, - ID: cds.ID, - }) - - }) - if err != nil { - t.Fatal(err) - } - if ds.ServiceID != testServiceID { - t.Errorf("bad sID: %q", ds.ServiceID) - } - if ds.ID != cds.ID { - t.Errorf("bad snipID: %q", ds.ID) - } - - // GETSnippet - var gs *Snippet - record(t, "vcl_snippets/get", func(c *Client) { - gs, err = c.GetSnippet(&GetSnippetInput{ - Service: testServiceID, - Name: testSnippetName, - Version: tv.Number, - }) - - }) - if err != nil { - t.Fatal(err) - } - if gs.Name != testSnippetName { - t.Errorf("bad name: %q", gs.Name) - } - if gs.ServiceID != testServiceID { - t.Errorf("bad service: %q", gs.ServiceID) - } - if gs.Content != content { - t.Errorf("bad content: %q", gs.Content) - } - - // Update - var us *Snippet - record(t, "vcl_snippets/update", func(c *Client) { - us, err = c.UpdateSnippet(&UpdateSnippetInput{ - Service: testServiceID, - Name: testSnippetName, - NewName: "newTestSnippetName", - Content: updatedDynContent, - Dynamic: 0, - Type: "none", - Priority: 50, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - - if us.Name != "newTestSnippetName" { - t.Errorf("bad updated name") - } - if us.Priority != 50 { - t.Errorf("bad priority: %d", us.Priority) - } - - if us.Content != updatedDynContent { - t.Errorf("bad content: %q", us.Content) - } - - if us.Type != "none" { - t.Errorf("bad type: %s", us.Type) - } - - // ListSnippets - var sl []*Snippet - record(t, "vcl_snippets/list", func(c *Client) { - sl, err = c.ListSnippets(&ListSnippetsInput{ - Service: testServiceID, - Version: tv.Number, - }) - - }) - if err != nil { - t.Fatal(err) - } - for _, x := range sl { - if x.ServiceID != testServiceID { - t.Errorf("bad service: %q", x.ServiceID) - } - if x.Version != tv.Number { - t.Errorf("bad Version: %q", x.Version) - } - } - - _, err = testClient.GetDynamicSnippet(&GetDynamicSnippetInput{ - Service: "", - }) - if err != ErrMissingService { - t.Errorf("bad error: %s", err) - } - _, err = testClient.GetDynamicSnippet(&GetDynamicSnippetInput{ - Service: testServiceID, - ID: "", - }) - if err != ErrMissingID { - t.Errorf("bad error: %s", err) - } - - _, err = testClient.CreateSnippet(&CreateSnippetInput{ - Service: testServiceID, - Version: tv.Number, - Name: testSnippetName, - Type: SnippetTypeRecv, - Priority: 100, - Dynamic: 0, - Content: "", - }) - - if err != ErrMissingContent { - t.Errorf("bad error: %s", err) - } } Index: golang-github-sethvargo-go-fastly/fastly/vcl_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/vcl_test.go 2019-08-21 23:08:10.893972822 +0000 +++ golang-github-sethvargo-go-fastly/fastly/vcl_test.go 2019-08-22 13:15:47.676605204 +0000 @@ -3,147 +3,6 @@ import "testing" func TestClient_VCLs(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "vcls/version", func(c *Client) { - tv = testVersion(t, c) - }) - - content := ` -backend default { - .host = "127.0.0.1"; - .port = "9092"; -} - -sub vcl_recv { - set req.backend = default; -} - -sub vcl_hash { - set req.hash += req.url; - set req.hash += req.http.host; - set req.hash += "0"; -} -` - - // Create - var vcl *VCL - record(t, "vcls/create", func(c *Client) { - vcl, err = c.CreateVCL(&CreateVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-vcl", - Content: content, - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "vcls/cleanup", func(c *Client) { - c.DeleteVCL(&DeleteVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-vcl", - }) - - c.DeleteVCL(&DeleteVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-vcl", - }) - }) - }() - - if vcl.Name != "test-vcl" { - t.Errorf("bad name: %q", vcl.Name) - } - if vcl.Content != content { - t.Errorf("bad content: %q", vcl.Content) - } - - // List - var vcls []*VCL - record(t, "vcls/list", func(c *Client) { - vcls, err = c.ListVCLs(&ListVCLsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(vcls) < 1 { - t.Errorf("bad vcls: %v", vcls) - } - - // Get - var nvcl *VCL - record(t, "vcls/get", func(c *Client) { - nvcl, err = c.GetVCL(&GetVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-vcl", - }) - }) - if err != nil { - t.Fatal(err) - } - if vcl.Name != nvcl.Name { - t.Errorf("bad name: %q", vcl.Name) - } - if vcl.Content != nvcl.Content { - t.Errorf("bad address: %q", vcl.Content) - } - - // Update - var uvcl *VCL - record(t, "vcls/update", func(c *Client) { - uvcl, err = c.UpdateVCL(&UpdateVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-vcl", - NewName: "new-test-vcl", - }) - }) - if err != nil { - t.Fatal(err) - } - if uvcl.Name != "new-test-vcl" { - t.Errorf("bad name: %q", uvcl.Name) - } - - // Activate - var avcl *VCL - record(t, "vcls/activate", func(c *Client) { - avcl, err = c.ActivateVCL(&ActivateVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-vcl", - }) - }) - if err != nil { - t.Fatal(err) - } - if avcl.Main != true { - t.Errorf("bad main: %t", avcl.Main) - } - - // Delete - record(t, "vcls/delete", func(c *Client) { - err = c.DeleteVCL(&DeleteVCLInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-vcl", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListVCLs_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/bigquery_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/bigquery_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/bigquery_test.go 2019-08-22 13:26:44.649818457 +0000 @@ -5,179 +5,6 @@ ) func TestClient_Bigqueries(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "bigqueries/version", func(c *Client) { - tv = testVersion(t, c) - }) - - var secretKey string - secretKey = privateKey() - - // Create - var bq *BigQuery - record(t, "bigqueries/create", func(c *Client) { - bq, err = c.CreateBigQuery(&CreateBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-bigquery", - ProjectID: "example-fastly-log", - Dataset: "fastly_log_test", - Table: "fastly_logs", - Template: "", - User: "fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com", - SecretKey: secretKey, - Format: "{\n \"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\",\n \"time_elapsed\":%{time.elapsed.usec}V,\n \"is_tls\":%{if(req.is_ssl, \"true\", \"false\")}V,\n \"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\n \"geo_city\":\"%{client.geo.city}V\",\n \"geo_country_code\":\"%{client.geo.country_code}V\",\n \"request\":\"%{req.request}V\",\n \"host\":\"%{req.http.Fastly-Orig-Host}V\",\n \"url\":\"%{json.escape(req.url)}V\",\n \"request_referer\":\"%{json.escape(req.http.Referer)}V\",\n \"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\n \"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\n \"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\n \"cache_status\":\"%{regsub(fastly_info.state, \"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\", \"\\\\2\\\\3\") }V\"\n}", - Placement: "waf_debug", - FormatVersion: 2, - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "bigqueries/cleanup", func(c *Client) { - c.DeleteBigQuery(&DeleteBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-bigquery", - }) - - c.DeleteBigQuery(&DeleteBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-bigquery", - }) - }) - }() - - if bq.Name != "test-bigquery" { - t.Errorf("bad name: %q", bq.Name) - } - if bq.ProjectID != "example-fastly-log" { - t.Errorf("bad project_id: %q", bq.ProjectID) - } - if bq.Dataset != "fastly_log_test" { - t.Errorf("bad dataset: %q", bq.Dataset) - } - if bq.Table != "fastly_logs" { - t.Errorf("bad table: %q", bq.Table) - } - if bq.Template != "" { - t.Errorf("bad template_suffix: %q", bq.Template) - } - if bq.User != "fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com" { - t.Errorf("bad user: %q", bq.User) - } - if bq.SecretKey != secretKey { - t.Errorf("bad secret_key: %q", bq.SecretKey) - } - if bq.Format != "{\n \"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\",\n \"time_elapsed\":%{time.elapsed.usec}V,\n \"is_tls\":%{if(req.is_ssl, \"true\", \"false\")}V,\n \"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\n \"geo_city\":\"%{client.geo.city}V\",\n \"geo_country_code\":\"%{client.geo.country_code}V\",\n \"request\":\"%{req.request}V\",\n \"host\":\"%{req.http.Fastly-Orig-Host}V\",\n \"url\":\"%{json.escape(req.url)}V\",\n \"request_referer\":\"%{json.escape(req.http.Referer)}V\",\n \"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\n \"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\n \"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\n \"cache_status\":\"%{regsub(fastly_info.state, \"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\", \"\\\\2\\\\3\") }V\"\n}" { - t.Errorf("bad format: %q", bq.Format) - } - if bq.ResponseCondition != "" { - t.Errorf("bad response_condition: %q", bq.ResponseCondition) - } - if bq.Placement != "waf_debug" { - t.Errorf("bad placement: %q", bq.Placement) - } - if bq.FormatVersion != 2 { - t.Errorf("bad format_version: %q", bq.FormatVersion) - } - - // List - var bqs []*BigQuery - record(t, "bigqueries/list", func(c *Client) { - bqs, err = c.ListBigQueries(&ListBigQueriesInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(bqs) < 1 { - t.Errorf("bad bigqueries: %v", bqs) - } - - // Get - var nbq *BigQuery - record(t, "bigqueries/get", func(c *Client) { - nbq, err = c.GetBigQuery(&GetBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-bigquery", - }) - }) - if err != nil { - t.Fatal(err) - } - if bq.Name != nbq.Name { - t.Errorf("bad name: %q", bq.Name) - } - if bq.ProjectID != nbq.ProjectID { - t.Errorf("bad project_id: %q", bq.ProjectID) - } - if bq.Dataset != nbq.Dataset { - t.Errorf("bad dataset: %q", bq.Dataset) - } - if bq.Table != nbq.Table { - t.Errorf("bad table: %q", bq.Table) - } - if bq.Template != nbq.Template { - t.Errorf("bad template_suffix: %q", bq.Template) - } - if bq.User != nbq.User { - t.Errorf("bad user: %q", bq.User) - } - if bq.SecretKey != nbq.SecretKey { - t.Errorf("bad secret_key: %q", bq.SecretKey) - } - if bq.Format != nbq.Format { - t.Errorf("bad format: %q", bq.Format) - } - if bq.ResponseCondition != nbq.ResponseCondition { - t.Errorf("bad response_condition: %q", bq.ResponseCondition) - } - if bq.Placement != nbq.Placement { - t.Errorf("bad placement: %q", bq.Placement) - } - if bq.FormatVersion != nbq.FormatVersion { - t.Errorf("bad format_version: %q", bq.FormatVersion) - } - - // Update - var ubq *BigQuery - record(t, "bigqueries/update", func(c *Client) { - ubq, err = c.UpdateBigQuery(&UpdateBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-bigquery", - NewName: "new-test-bigquery", - }) - }) - if err != nil { - t.Fatal(err) - } - if ubq.Name != "new-test-bigquery" { - t.Errorf("bad name: %q", ubq.Name) - } - - // Delete - record(t, "bigqueries/delete", func(c *Client) { - err = c.DeleteBigQuery(&DeleteBigQueryInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-bigquery", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListBigQueries_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/ip_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/ip_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/ip_test.go 2019-08-22 13:31:34.402702702 +0000 @@ -3,17 +3,4 @@ import "testing" func TestClient_IPs(t *testing.T) { - t.Parallel() - - var err error - var ips IPAddrs - record(t, "ips/list", func(c *Client) { - ips, err = c.IPs() - }) - if err != nil { - t.Fatal(err) - } - if len(ips) == 0 { - t.Fatal("missing ips") - } } Index: golang-github-sethvargo-go-fastly/fastly/realtime_stats_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/realtime_stats_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/realtime_stats_test.go 2019-08-22 13:29:56.682357432 +0000 @@ -13,19 +13,4 @@ } func TestStatsClient_GetRealtimeStats(t *testing.T) { - t.Parallel() - - var err error - - // Get - recordRealtimeStats(t, "realtime_stats/get", func(c *RTSClient) { - _, err = c.GetRealtimeStats(&GetRealtimeStatsInput{ - Service: testServiceID, - Timestamp: 0, - Limit: 3, - }) - }) - if err != nil { - t.Fatal(err) - } } Index: golang-github-sethvargo-go-fastly/fastly/request_setting_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/request_setting_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/request_setting_test.go 2019-08-22 13:32:19.656714996 +0000 @@ -3,177 +3,6 @@ import "testing" func TestClient_RequestSettings(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "request_settings/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var rs *RequestSetting - record(t, "request_settings/create", func(c *Client) { - rs, err = c.CreateRequestSetting(&CreateRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-request-setting", - ForceMiss: CBool(true), - ForceSSL: CBool(true), - Action: RequestSettingActionLookup, - BypassBusyWait: CBool(true), - MaxStaleAge: 30, - HashKeys: "a,b,c", - XForwardedFor: RequestSettingXFFLeave, - TimerSupport: CBool(true), - GeoHeaders: CBool(true), - DefaultHost: "example.com", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "request_settings/cleanup", func(c *Client) { - c.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-request-setting", - }) - - c.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-request-setting", - }) - }) - }() - - if rs.Name != "test-request-setting" { - t.Errorf("bad name: %q", rs.Name) - } - if rs.ForceMiss != true { - t.Errorf("bad force_miss: %t", rs.ForceMiss) - } - if rs.ForceSSL != true { - t.Errorf("bad force_ssl: %t", rs.ForceSSL) - } - if rs.Action != RequestSettingActionLookup { - t.Errorf("bad action: %q", rs.Action) - } - if rs.BypassBusyWait != true { - t.Errorf("bad bypass_busy_wait: %t", rs.BypassBusyWait) - } - if rs.MaxStaleAge != 30 { - t.Errorf("bad max_stale_age: %d", rs.MaxStaleAge) - } - if rs.HashKeys != "a,b,c" { - t.Errorf("bad has_keys: %q", rs.HashKeys) - } - if rs.XForwardedFor != RequestSettingXFFLeave { - t.Errorf("bad xff: %q", rs.XForwardedFor) - } - if rs.TimerSupport != true { - t.Errorf("bad timer_support: %t", rs.TimerSupport) - } - if rs.GeoHeaders != true { - t.Errorf("bad geo_headers: %t", rs.GeoHeaders) - } - if rs.DefaultHost != "example.com" { - t.Errorf("bad default_host: %q", rs.DefaultHost) - } - - // List - var rss []*RequestSetting - record(t, "request_settings/list", func(c *Client) { - rss, err = c.ListRequestSettings(&ListRequestSettingsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(rss) < 1 { - t.Errorf("bad request settings: %v", rss) - } - - // Get - var nrs *RequestSetting - record(t, "request_settings/get", func(c *Client) { - nrs, err = c.GetRequestSetting(&GetRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-request-setting", - }) - }) - if err != nil { - t.Fatal(err) - } - if rs.Name != nrs.Name { - t.Errorf("bad name: %q (%q)", rs.Name, nrs.Name) - } - if rs.ForceMiss != nrs.ForceMiss { - t.Errorf("bad force_miss: %t (%t)", rs.ForceMiss, nrs.ForceMiss) - } - if rs.ForceSSL != rs.ForceSSL { - t.Errorf("bad force_ssl: %t (%t)", rs.ForceSSL, nrs.ForceSSL) - } - if rs.Action != nrs.Action { - t.Errorf("bad action: %q (%q)", rs.Action, nrs.Action) - } - if rs.BypassBusyWait != nrs.BypassBusyWait { - t.Errorf("bad bypass_busy_wait: %t (%t)", rs.BypassBusyWait, nrs.BypassBusyWait) - } - if rs.MaxStaleAge != nrs.MaxStaleAge { - t.Errorf("bad max_stale_age: %d (%d)", rs.MaxStaleAge, nrs.MaxStaleAge) - } - if rs.HashKeys != nrs.HashKeys { - t.Errorf("bad has_keys: %q (%q)", rs.HashKeys, nrs.HashKeys) - } - if rs.XForwardedFor != nrs.XForwardedFor { - t.Errorf("bad xff: %q (%q)", rs.XForwardedFor, nrs.XForwardedFor) - } - if rs.TimerSupport != nrs.TimerSupport { - t.Errorf("bad timer_support: %t (%t)", rs.TimerSupport, nrs.TimerSupport) - } - if rs.GeoHeaders != nrs.GeoHeaders { - t.Errorf("bad geo_headers: %t (%t)", rs.GeoHeaders, nrs.GeoHeaders) - } - if rs.DefaultHost != nrs.DefaultHost { - t.Errorf("bad default_host: %q (%q)", rs.DefaultHost, nrs.DefaultHost) - } - - // Update - var urs *RequestSetting - record(t, "request_settings/update", func(c *Client) { - urs, err = c.UpdateRequestSetting(&UpdateRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-request-setting", - NewName: "new-test-request-setting", - }) - }) - if err != nil { - t.Fatal(err) - } - if urs.Name != "new-test-request-setting" { - t.Errorf("bad name: %q", urs.Name) - } - - // Delete - record(t, "request_settings/delete", func(c *Client) { - err = c.DeleteRequestSetting(&DeleteRequestSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-request-setting", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListRequestSettings_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/response_object_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/response_object_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/response_object_test.go 2019-08-22 13:30:39.268251089 +0000 @@ -3,135 +3,6 @@ import "testing" func TestClient_ResponseObjects(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "response_objects/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var ro *ResponseObject - record(t, "response_objects/create", func(c *Client) { - ro, err = c.CreateResponseObject(&CreateResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", - Status: 200, - Response: "Ok", - Content: "abcd", - ContentType: "text/plain", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "response_objects/cleanup", func(c *Client) { - c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", - }) - - c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-response-object", - }) - }) - }() - - if ro.Name != "test-response-object" { - t.Errorf("bad name: %q", ro.Name) - } - if ro.Status != 200 { - t.Errorf("bad status: %q", ro.Status) - } - if ro.Response != "Ok" { - t.Errorf("bad response: %q", ro.Response) - } - if ro.Content != "abcd" { - t.Errorf("bad content: %q", ro.Content) - } - if ro.ContentType != "text/plain" { - t.Errorf("bad content_type: %q", ro.ContentType) - } - - // List - var ros []*ResponseObject - record(t, "response_objects/list", func(c *Client) { - ros, err = c.ListResponseObjects(&ListResponseObjectsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ros) < 1 { - t.Errorf("bad response objects: %v", ros) - } - - // Get - var nro *ResponseObject - record(t, "response_objects/get", func(c *Client) { - nro, err = c.GetResponseObject(&GetResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", - }) - }) - if err != nil { - t.Fatal(err) - } - if ro.Name != nro.Name { - t.Errorf("bad name: %q", ro.Name) - } - if ro.Status != nro.Status { - t.Errorf("bad status: %q", ro.Status) - } - if ro.Response != nro.Response { - t.Errorf("bad response: %q", ro.Response) - } - if ro.Content != nro.Content { - t.Errorf("bad content: %q", ro.Content) - } - if ro.ContentType != nro.ContentType { - t.Errorf("bad content_type: %q", ro.ContentType) - } - - // Update - var uro *ResponseObject - record(t, "response_objects/update", func(c *Client) { - uro, err = c.UpdateResponseObject(&UpdateResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-response-object", - NewName: "new-test-response-object", - }) - }) - if err != nil { - t.Fatal(err) - } - if uro.Name != "new-test-response-object" { - t.Errorf("bad name: %q", uro.Name) - } - - // Delete - record(t, "response_objects/delete", func(c *Client) { - err = c.DeleteResponseObject(&DeleteResponseObjectInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-response-object", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListResponseObjects_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/s3_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/s3_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/s3_test.go 2019-08-22 13:28:33.062639167 +0000 @@ -3,195 +3,6 @@ import "testing" func TestClient_S3s(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "s3s/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var s3 *S3 - record(t, "s3s/create", func(c *Client) { - s3, err = c.CreateS3(&CreateS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "test-s3", - BucketName: "bucket-name", - Domain: "s3.us-east-1.amazonaws.com", - AccessKey: "AKIAIOSFODNN7EXAMPLE", - SecretKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", - Path: "/path", - Period: 12, - GzipLevel: 9, - Format: "format", - FormatVersion: 2, - TimestampFormat: "%Y", - MessageType: "classic", - Redundancy: S3RedundancyReduced, - Placement: "waf_debug", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "s3s/cleanup", func(c *Client) { - c.DeleteS3(&DeleteS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "test-s3", - }) - - c.DeleteS3(&DeleteS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-s3", - }) - }) - }() - - if s3.Name != "test-s3" { - t.Errorf("bad name: %q", s3.Name) - } - if s3.BucketName != "bucket-name" { - t.Errorf("bad bucket_name: %q", s3.BucketName) - } - if s3.AccessKey != "AKIAIOSFODNN7EXAMPLE" { - t.Errorf("bad access_key: %q", s3.AccessKey) - } - if s3.SecretKey != "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" { - t.Errorf("bad secret_key: %q", s3.SecretKey) - } - if s3.Domain != "s3.us-east-1.amazonaws.com" { - t.Errorf("bad domain: %q", s3.Domain) - } - if s3.Path != "/path" { - t.Errorf("bad path: %q", s3.Path) - } - if s3.Period != 12 { - t.Errorf("bad period: %q", s3.Period) - } - if s3.GzipLevel != 9 { - t.Errorf("bad gzip_level: %q", s3.GzipLevel) - } - if s3.Format != "format" { - t.Errorf("bad format: %q", s3.Format) - } - if s3.FormatVersion != 2 { - t.Errorf("bad format_version: %q", s3.FormatVersion) - } - if s3.TimestampFormat != "%Y" { - t.Errorf("bad timestamp_format: %q", s3.TimestampFormat) - } - if s3.Redundancy != S3RedundancyReduced { - t.Errorf("bad redundancy: %q", s3.Redundancy) - } - if s3.MessageType != "classic" { - t.Errorf("bad message_type: %q", s3.MessageType) - } - if s3.Placement != "waf_debug" { - t.Errorf("bad placement: %q", s3.Placement) - } - - // List - var s3s []*S3 - record(t, "s3s/list", func(c *Client) { - s3s, err = c.ListS3s(&ListS3sInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(s3s) < 1 { - t.Errorf("bad s3s: %v", s3s) - } - - // Get - var ns3 *S3 - record(t, "s3s/get", func(c *Client) { - ns3, err = c.GetS3(&GetS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "test-s3", - }) - }) - if err != nil { - t.Fatal(err) - } - if s3.Name != ns3.Name { - t.Errorf("bad name: %q", s3.Name) - } - if s3.BucketName != ns3.BucketName { - t.Errorf("bad bucket_name: %q", s3.BucketName) - } - if s3.AccessKey != ns3.AccessKey { - t.Errorf("bad access_key: %q", s3.AccessKey) - } - if s3.SecretKey != ns3.SecretKey { - t.Errorf("bad secret_key: %q", s3.SecretKey) - } - if s3.Domain != ns3.Domain { - t.Errorf("bad domain: %q", s3.Domain) - } - if s3.Path != ns3.Path { - t.Errorf("bad path: %q", s3.Path) - } - if s3.Period != ns3.Period { - t.Errorf("bad period: %q", s3.Period) - } - if s3.GzipLevel != ns3.GzipLevel { - t.Errorf("bad gzip_level: %q", s3.GzipLevel) - } - if s3.Format != ns3.Format { - t.Errorf("bad format: %q", s3.Format) - } - if s3.FormatVersion != ns3.FormatVersion { - t.Errorf("bad format_version: %q", s3.FormatVersion) - } - if s3.TimestampFormat != ns3.TimestampFormat { - t.Errorf("bad timestamp_format: %q", s3.TimestampFormat) - } - if s3.Redundancy != ns3.Redundancy { - t.Errorf("bad redundancy: %q", s3.Redundancy) - } - if s3.Placement != ns3.Placement { - t.Errorf("bad placement: %q", s3.Placement) - } - - // Update - var us3 *S3 - record(t, "s3s/update", func(c *Client) { - us3, err = c.UpdateS3(&UpdateS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "test-s3", - NewName: "new-test-s3", - }) - }) - if err != nil { - t.Fatal(err) - } - if us3.Name != "new-test-s3" { - t.Errorf("bad name: %q", us3.Name) - } - - // Delete - record(t, "s3s/delete", func(c *Client) { - err = c.DeleteS3(&DeleteS3Input{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-s3", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListS3s_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/settings_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/settings_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/settings_test.go 2019-08-22 13:27:58.813116214 +0000 @@ -8,52 +8,6 @@ ) func TestClient_Settings(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "settings/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Get - var ns *Settings - record(t, "settings/get", func(c *Client) { - ns, err = c.GetSettings(&GetSettingsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if ns.DefaultTTL == 0 { - t.Errorf("bad default_ttl: %d", ns.DefaultTTL) - } - - // Update - var us *Settings - record(t, "settings/update", func(c *Client) { - us, err = c.UpdateSettings(&UpdateSettingsInput{ - Service: testServiceID, - Version: tv.Number, - DefaultTTL: 1800, - StaleIfError: true, - StaleIfErrorTTL: 57600, - }) - }) - if err != nil { - t.Fatal(err) - } - if us.DefaultTTL != 1800 { - t.Errorf("bad default_ttl: %d", us.DefaultTTL) - } - if us.StaleIfError != true { - t.Errorf("bad stale_if_error: %t", us.StaleIfError) - } - if us.StaleIfErrorTTL != 57600 { - t.Errorf("bad stale_if_error_ttl %d", us.StaleIfErrorTTL) - } } // Tests if we can update a default_ttl to 0 as reported in issue #20 Index: golang-github-sethvargo-go-fastly/fastly/splunk_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/splunk_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/splunk_test.go 2019-08-22 13:27:18.451321477 +0000 @@ -3,142 +3,6 @@ import "testing" func TestClient_Splunks(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "splunks/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var s *Splunk - record(t, "splunks/create", func(c *Client) { - s, err = c.CreateSplunk(&CreateSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-splunk", - URL: "https://mysplunkendpoint.example.com/services/collector/event", - Format: "%h %l %u %t \"%r\" %>s %b", - FormatVersion: 2, - Placement: "waf_debug", - Token: "super-secure-token", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "splunks/cleanup", func(c *Client) { - c.DeleteSplunk(&DeleteSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-splunk", - }) - - c.DeleteSplunk(&DeleteSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-splunk", - }) - }) - }() - - if s.Name != "test-splunk" { - t.Errorf("bad name: %q", s.Name) - } - if s.URL != "https://mysplunkendpoint.example.com/services/collector/event" { - t.Errorf("bad url: %q", s.URL) - } - if s.Format != "%h %l %u %t \"%r\" %>s %b" { - t.Errorf("bad format: %q", s.Format) - } - if s.FormatVersion != 2 { - t.Errorf("bad format_version: %q", s.FormatVersion) - } - if s.Placement != "waf_debug" { - t.Errorf("bad placement: %q", s.Placement) - } - if s.Token != "super-secure-token" { - t.Errorf("bad token: %q", s.Token) - } - - // List - var ss []*Splunk - record(t, "splunks/list", func(c *Client) { - ss, err = c.ListSplunks(&ListSplunksInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ss) < 1 { - t.Errorf("bad splunks: %v", ss) - } - - // Get - var ns *Splunk - record(t, "splunks/get", func(c *Client) { - ns, err = c.GetSplunk(&GetSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-splunk", - }) - }) - if err != nil { - t.Fatal(err) - } - if s.Name != ns.Name { - t.Errorf("bad name: %q", s.Name) - } - if s.URL != ns.URL { - t.Errorf("bad url: %q", s.URL) - } - if s.Format != ns.Format { - t.Errorf("bad format: %q", s.Format) - } - if s.FormatVersion != ns.FormatVersion { - t.Errorf("bad format_version: %q", s.FormatVersion) - } - if s.Placement != ns.Placement { - t.Errorf("bad placement: %q", s.Placement) - } - if s.Token != ns.Token { - t.Errorf("bad token: %q", s.Token) - } - - // Update - var us *Splunk - record(t, "splunks/update", func(c *Client) { - us, err = c.UpdateSplunk(&UpdateSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-splunk", - NewName: "new-test-splunk", - }) - }) - if err != nil { - t.Fatal(err) - } - if us.Name != "new-test-splunk" { - t.Errorf("bad name: %q", us.Name) - } - - // Delete - record(t, "splunks/delete", func(c *Client) { - err = c.DeleteSplunk(&DeleteSplunkInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-splunk", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListSplunks_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/blobstorage_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/blobstorage_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/blobstorage_test.go 2019-08-22 13:44:38.461566976 +0000 @@ -3,191 +3,6 @@ import "testing" func TestClient_BlobStorages(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "blobstorages/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var bs *BlobStorage - record(t, "blobstorages/create", func(c *Client) { - bs, err = c.CreateBlobStorage(&CreateBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-blobstorage", - Path: "/logs", - AccountName: "test", - Container: "fastly", - SASToken: "sv=2015-04-05&ss=b&srt=sco&sp=rw&se=2019-07-21T18%3A00%3A00Z&sig=3ABdLOJZosCp0o491T%2BqZGKIhafF1nlM3MzESDDD3Gg%3D", - Period: 12, - TimestampFormat: "%Y-%m-%dT%H:%M:%S.000", - GzipLevel: 9, - PublicKey: "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQENBFyUD8sBCACyFnB39AuuTygseek+eA4fo0cgwva6/FSjnWq7riouQee8GgQ/\nibXTRyv4iVlwI12GswvMTIy7zNvs1R54i0qvsLr+IZ4GVGJqs6ZJnvQcqe3xPoR4\n8AnBfw90o32r/LuHf6QCJXi+AEu35koNlNAvLJ2B+KACaNB7N0EeWmqpV/1V2k9p\nlDYk+th7LcCuaFNGqKS/PrMnnMqR6VDLCjHhNx4KR79b0Twm/2qp6an3hyNRu8Gn\ndwxpf1/BUu3JWf+LqkN4Y3mbOmSUL3MaJNvyQguUzTfS0P0uGuBDHrJCVkMZCzDB\n89ag55jCPHyGeHBTd02gHMWzsg3WMBWvCsrzABEBAAG0JXRlcnJhZm9ybSAodGVz\ndCkgPHRlc3RAdGVycmFmb3JtLmNvbT6JAU4EEwEIADgWIQSHYyc6Kj9l6HzQsau6\nvFFc9jxV/wUCXJQPywIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRC6vFFc\n9jxV/815CAClb32OxV7wG01yF97TzlyTl8TnvjMtoG29Mw4nSyg+mjM3b8N7iXm9\nOLX59fbDAWtBSldSZE22RXd3CvlFOG/EnKBXSjBtEqfyxYSnyOPkMPBYWGL/ApkX\nSvPYJ4LKdvipYToKFh3y9kk2gk1DcDBDyaaHvR+3rv1u3aoy7/s2EltAfDS3ZQIq\n7/cWTLJml/lleeB/Y6rPj8xqeCYhE5ahw9gsV/Mdqatl24V9Tks30iijx0Hhw+Gx\nkATUikMGr2GDVqoIRga5kXI7CzYff4rkc0Twn47fMHHHe/KY9M2yVnMHUXmAZwbG\nM1cMI/NH1DjevCKdGBLcRJlhuLPKF/anuQENBFyUD8sBCADIpd7r7GuPd6n/Ikxe\nu6h7umV6IIPoAm88xCYpTbSZiaK30Svh6Ywra9jfE2KlU9o6Y/art8ip0VJ3m07L\n4RSfSpnzqgSwdjSq5hNour2Fo/BzYhK7yaz2AzVSbe33R0+RYhb4b/6N+bKbjwGF\nftCsqVFMH+PyvYkLbvxyQrHlA9woAZaNThI1ztO5rGSnGUR8xt84eup28WIFKg0K\nUEGUcTzz+8QGAwAra+0ewPXo/AkO+8BvZjDidP417u6gpBHOJ9qYIcO9FxHeqFyu\nYrjlrxowEgXn5wO8xuNz6Vu1vhHGDHGDsRbZF8pv1d5O+0F1G7ttZ2GRRgVBZPwi\nkiyRABEBAAGJATYEGAEIACAWIQSHYyc6Kj9l6HzQsau6vFFc9jxV/wUCXJQPywIb\nDAAKCRC6vFFc9jxV/9YOCACe8qmOSnKQpQfW+PqYOqo3dt7JyweTs3FkD6NT8Zml\ndYy/vkstbTjPpX6aTvUZjkb46BVi7AOneVHpD5GBqvRsZ9iVgDYHaehmLCdKiG5L\n3Tp90NN+QY5WDbsGmsyk6+6ZMYejb4qYfweQeduOj27aavCJdLkCYMoRKfcFYI8c\nFaNmEfKKy/r1PO20NXEG6t9t05K/frHy6ZG8bCNYdpagfFVot47r9JaQqWlTNtIR\n5+zkkSq/eG9BEtRij3a6cTdQbktdBzx2KBeI0PYc1vlZR0LpuFKZqY9vlE6vTGLR\nwMfrTEOvx0NxUM3rpaCgEmuWbB1G1Hu371oyr4srrr+N\n=28dr\n-----END PGP PUBLIC KEY BLOCK-----\n", - Format: "%h %l %u %{now}V %{req.method}V %{req.url}V %>s %{resp.http.Content-Length}V", - FormatVersion: 2, - MessageType: "classic", - Placement: "waf_debug", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "blobstorages/cleanup", func(c *Client) { - c.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-blobstorage", - }) - - c.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-blobstorage", - }) - }) - }() - - if bs.Name != "test-blobstorage" { - t.Errorf("bad name: %q", bs.Name) - } - if bs.Path != "/logs" { - t.Errorf("bad path: %q", bs.Path) - } - if bs.AccountName != "test" { - t.Errorf("bad account_name: %q", bs.AccountName) - } - if bs.Container != "fastly" { - t.Errorf("bad container: %q", bs.Container) - } - if bs.SASToken != "sv=2015-04-05&ss=b&srt=sco&sp=rw&se=2019-07-21T18%3A00%3A00Z&sig=3ABdLOJZosCp0o491T%2BqZGKIhafF1nlM3MzESDDD3Gg%3D" { - t.Errorf("bad sas_token: %q", bs.SASToken) - } - if bs.Period != 12 { - t.Errorf("bad period: %q", bs.Period) - } - if bs.TimestampFormat != "%Y-%m-%dT%H:%M:%S.000" { - t.Errorf("bad timestamp_format: %q", bs.TimestampFormat) - } - if bs.GzipLevel != 9 { - t.Errorf("bad gzip_level: %q", bs.GzipLevel) - } - if bs.PublicKey != "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQENBFyUD8sBCACyFnB39AuuTygseek+eA4fo0cgwva6/FSjnWq7riouQee8GgQ/\nibXTRyv4iVlwI12GswvMTIy7zNvs1R54i0qvsLr+IZ4GVGJqs6ZJnvQcqe3xPoR4\n8AnBfw90o32r/LuHf6QCJXi+AEu35koNlNAvLJ2B+KACaNB7N0EeWmqpV/1V2k9p\nlDYk+th7LcCuaFNGqKS/PrMnnMqR6VDLCjHhNx4KR79b0Twm/2qp6an3hyNRu8Gn\ndwxpf1/BUu3JWf+LqkN4Y3mbOmSUL3MaJNvyQguUzTfS0P0uGuBDHrJCVkMZCzDB\n89ag55jCPHyGeHBTd02gHMWzsg3WMBWvCsrzABEBAAG0JXRlcnJhZm9ybSAodGVz\ndCkgPHRlc3RAdGVycmFmb3JtLmNvbT6JAU4EEwEIADgWIQSHYyc6Kj9l6HzQsau6\nvFFc9jxV/wUCXJQPywIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRC6vFFc\n9jxV/815CAClb32OxV7wG01yF97TzlyTl8TnvjMtoG29Mw4nSyg+mjM3b8N7iXm9\nOLX59fbDAWtBSldSZE22RXd3CvlFOG/EnKBXSjBtEqfyxYSnyOPkMPBYWGL/ApkX\nSvPYJ4LKdvipYToKFh3y9kk2gk1DcDBDyaaHvR+3rv1u3aoy7/s2EltAfDS3ZQIq\n7/cWTLJml/lleeB/Y6rPj8xqeCYhE5ahw9gsV/Mdqatl24V9Tks30iijx0Hhw+Gx\nkATUikMGr2GDVqoIRga5kXI7CzYff4rkc0Twn47fMHHHe/KY9M2yVnMHUXmAZwbG\nM1cMI/NH1DjevCKdGBLcRJlhuLPKF/anuQENBFyUD8sBCADIpd7r7GuPd6n/Ikxe\nu6h7umV6IIPoAm88xCYpTbSZiaK30Svh6Ywra9jfE2KlU9o6Y/art8ip0VJ3m07L\n4RSfSpnzqgSwdjSq5hNour2Fo/BzYhK7yaz2AzVSbe33R0+RYhb4b/6N+bKbjwGF\nftCsqVFMH+PyvYkLbvxyQrHlA9woAZaNThI1ztO5rGSnGUR8xt84eup28WIFKg0K\nUEGUcTzz+8QGAwAra+0ewPXo/AkO+8BvZjDidP417u6gpBHOJ9qYIcO9FxHeqFyu\nYrjlrxowEgXn5wO8xuNz6Vu1vhHGDHGDsRbZF8pv1d5O+0F1G7ttZ2GRRgVBZPwi\nkiyRABEBAAGJATYEGAEIACAWIQSHYyc6Kj9l6HzQsau6vFFc9jxV/wUCXJQPywIb\nDAAKCRC6vFFc9jxV/9YOCACe8qmOSnKQpQfW+PqYOqo3dt7JyweTs3FkD6NT8Zml\ndYy/vkstbTjPpX6aTvUZjkb46BVi7AOneVHpD5GBqvRsZ9iVgDYHaehmLCdKiG5L\n3Tp90NN+QY5WDbsGmsyk6+6ZMYejb4qYfweQeduOj27aavCJdLkCYMoRKfcFYI8c\nFaNmEfKKy/r1PO20NXEG6t9t05K/frHy6ZG8bCNYdpagfFVot47r9JaQqWlTNtIR\n5+zkkSq/eG9BEtRij3a6cTdQbktdBzx2KBeI0PYc1vlZR0LpuFKZqY9vlE6vTGLR\nwMfrTEOvx0NxUM3rpaCgEmuWbB1G1Hu371oyr4srrr+N\n=28dr\n-----END PGP PUBLIC KEY BLOCK-----\n" { - t.Errorf("bad public_key: %q", bs.PublicKey) - } - if bs.Format != "%h %l %u %{now}V %{req.method}V %{req.url}V %>s %{resp.http.Content-Length}V" { - t.Errorf("bad format: %q", bs.Format) - } - if bs.FormatVersion != 2 { - t.Errorf("bad format_version: %q", bs.FormatVersion) - } - if bs.MessageType != "classic" { - t.Errorf("bad message_type: %q", bs.MessageType) - } - if bs.Placement != "waf_debug" { - t.Errorf("bad placement: %q", bs.Placement) - } - - // List - var bsl []*BlobStorage - record(t, "blobstorages/list", func(c *Client) { - bsl, err = c.ListBlobStorages(&ListBlobStoragesInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(bsl) < 1 { - t.Errorf("bad blob storages: %v", bsl) - } - - // Get - var nbs *BlobStorage - record(t, "blobstorages/get", func(c *Client) { - nbs, err = c.GetBlobStorage(&GetBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-blobstorage", - }) - }) - if err != nil { - t.Fatal(err) - } - if bs.Name != nbs.Name { - t.Errorf("bad name: %q", bs.Name) - } - if bs.Path != nbs.Path { - t.Errorf("bad path: %q", bs.Path) - } - if bs.AccountName != nbs.AccountName { - t.Errorf("bad account_name: %q", bs.AccountName) - } - if bs.Container != nbs.Container { - t.Errorf("bad container: %q", bs.Container) - } - if bs.SASToken != nbs.SASToken { - t.Errorf("bad sas_token: %q", bs.SASToken) - } - if bs.Period != nbs.Period { - t.Errorf("bad period: %q", bs.Period) - } - if bs.TimestampFormat != nbs.TimestampFormat { - t.Errorf("bad timestamp_format: %q", bs.TimestampFormat) - } - if bs.GzipLevel != nbs.GzipLevel { - t.Errorf("bad gzip_level: %q", bs.GzipLevel) - } - if bs.PublicKey != nbs.PublicKey { - t.Errorf("bad public_key: %q", bs.PublicKey) - } - if bs.Format != nbs.Format { - t.Errorf("bad format: %q", bs.Format) - } - if bs.FormatVersion != nbs.FormatVersion { - t.Errorf("bad format_version: %q", bs.FormatVersion) - } - if bs.MessageType != nbs.MessageType { - t.Errorf("bad message_type: %q", bs.MessageType) - } - if bs.Placement != nbs.Placement { - t.Errorf("bad placement: %q", bs.Placement) - } - - // Update - var ubs *BlobStorage - record(t, "blobstorages/update", func(c *Client) { - ubs, err = c.UpdateBlobStorage(&UpdateBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-blobstorage", - NewName: "new-test-blobstorage", - }) - }) - if err != nil { - t.Fatal(err) - } - if ubs.Name != "new-test-blobstorage" { - t.Errorf("bad name: %q", ubs.Name) - } - - // Delete - record(t, "blobstorages/delete", func(c *Client) { - err = c.DeleteBlobStorage(&DeleteBlobStorageInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-blobstorage", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListBlobStorages_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/event_logs_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/event_logs_test.go 2019-08-21 23:08:10.833970154 +0000 +++ golang-github-sethvargo-go-fastly/fastly/event_logs_test.go 2019-08-22 13:48:29.503840593 +0000 @@ -9,36 +9,6 @@ var testEventID = "3OMewexIMbzrQj77xxxxxx" func TestClient_APIEvents(t *testing.T) { - t.Parallel() - - var err error - var events GetAPIEventsResponse - record(t, "events/get_events", func(c *Client) { - events, err = c.GetAPIEvents(&GetAPIEventsFilterInput{ - PageNumber: 1, - MaxResults: 1, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(events.Events) < 1 { - t.Errorf("bad events: %v", events.Events) - } - - var event *Event - record(t, "events/get_event", func(c *Client) { - event, err = c.GetAPIEvent(&GetAPIEventInput{ - EventID: events.Events[0].ID, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(event.ID) < 1 { - t.Errorf("bad event: %v", event) - } - } func TestClient_GetAPIEvent_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/gcs_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/gcs_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/gcs_test.go 2019-08-22 13:49:09.373613459 +0000 @@ -3,184 +3,6 @@ import "testing" func TestClient_GCSs(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "gcses/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var gcs *GCS - record(t, "gcses/create", func(c *Client) { - gcs, err = c.CreateGCS(&CreateGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gcs", - Bucket: "bucket", - User: "user", - SecretKey: "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n", - Path: "/path", - Period: 12, - GzipLevel: 9, - FormatVersion: 2, - Format: "format", - MessageType: "blank", - TimestampFormat: "%Y", - Placement: "waf_debug", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "gcses/cleanup", func(c *Client) { - c.DeleteGCS(&DeleteGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gcs", - }) - - c.DeleteGCS(&DeleteGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-gcs", - }) - }) - }() - - if gcs.Name != "test-gcs" { - t.Errorf("bad name: %q", gcs.Name) - } - if gcs.Bucket != "bucket" { - t.Errorf("bad bucket: %q", gcs.Bucket) - } - if gcs.User != "user" { - t.Errorf("bad user: %q", gcs.User) - } - if gcs.SecretKey != "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9aQoqdHVA86oq\nTdRQ5HqwMfpiLBBMKNQcAJsO71RKNrDWwJJZiyYbvM4FOWRZFtRSdPIDgX0C0Wg1\nNnqWYvHDyA5Ug+T8kowiQDn56dU6Km2FWO4wnqZeA8q5G7rQVXlqdibuiP7FglHA\neURUzFsqyymXMUGrqDPqrHsVWC2E3NTJEb4QlywtrwI13qbhlvTx6/9oRfUjytXJ\nRuUIE5xL8yhRCagNr5ZW250aa+wBwu5DSCk5fDNr0eDuZjw84WHDll+mHxBFGV+X\nKJ5jCOmGumGqjVWZesJpNN1My3M9bsY9layNJJ0eiDeHDEi/yXhhO/mNEXhvhq/R\nfN0Jh2A3AgMBAAECggEAef+CEL5aF6/aVs0yh7fiXkKSp1ECXkud8ztgpEn63KJF\nXM1EdnBt50fA2xSQUeGmeEXi6+cngf0nRb8FToAEgLoGoOEjSJuLrzP3I8U9Fe3m\nBRG2uZI2Ti/bD0eRGEc1oSDhCpsqnkTGK1bwcD4AKpwY+c08Izh/2BOoY6McDoqh\ndQ89jzTuMtD4cNlnPiIrY9HbxoNjshK2ax1OaeXyYKZFG1TxqMFv5gA/G5+S3Cwr\nVG4fkAxYi5vdIK3b8jUXrTM/kpoTl+d3dlQ7rRZYf7KyT31/HtJ/GNzxFI6upzO7\niDNrrUOyeOPjWXdzUh9budv3j+6UfbYK7uZIoebHIQKBgQDykYX1L/akGaOC2tfS\njzCWUzPxGFYVZQ7zD1PM6UyouuS1KLURDEGk9RxqVzTPh/pYd8Ivnz3vOVski5Zt\n19ozLGxdtDhn122DcnVpfCdYzHBdAzPCzORenFohX+MhiX5fEotTlVi7wfOmzTP5\nhUCMSd/17bJrV4XMLhkdrMRBFQKBgQDH5fwV7o+Ej/ZfcdGIa3mAFazToPDzxhHU\nnwADxaxpNGKRU03XCaiYkykarLYdG6Rk+7dXUv8eLy+6Dcq1SWQtfCWKEor++IIp\n1RwWmFHfYriHGkmxSkkEkLFvL8old9xM5YWbEXc4QIXvnfR4BZxdyJHVzIDdbI2i\nFgcn17U3GwKBgDd1njMY7ENIuWHJt16k7m7wRwfwkH4DxQ89ieNn0+cgE/p3fC6R\nptCYWg7WMXThmhNwDi3lMrvnWTdZ0uL6XyEkHwKtmdfkIV3UZZPglv5uf6JEgSkg\nv3YCOXk3+y5HyWTjUIejtc334kVY1XFPThrFKTeJSSnRsP2l7IgkYBqhAoGAYGsr\nM3z1FrDF2nWw5odIfKJ30UAw2LRyB0eGH0uqhLgyzvwKcK2E98sLqYUi9llN6zOK\n1IEA8xM5hxl97AFxY4sdJEMbbi55wim7uZ5Q51nbvbbNUsmM/Lm6C/JWI8pzpVeU\nIR7EjYp50AE1WOsD6CyFQ0W35pWkn0jWvL4L938CgYEAlax4dLE5+YCG5DeLT1/N\nin6kQjl7JS4oCNlPEj6aRPLX2OJresI7oOn+uNatKvlVyfPm6rdxeHCmER1FpR7Q\nA/aNVjPeViKT/R4nK9ytsa+s/1IJVrwLFHJK3toGE660g5w3vKrCjWisMdP4yzzQ\nbv1KwcKoQbNVXwauH79JKc0=\n-----END PRIVATE KEY-----\n" { - t.Errorf("bad secret_key: %q", gcs.SecretKey) - } - if gcs.Path != "/path" { - t.Errorf("bad path: %q", gcs.Path) - } - if gcs.Period != 12 { - t.Errorf("bad period: %q", gcs.Period) - } - if gcs.GzipLevel != 9 { - t.Errorf("bad gzip_level: %q", gcs.GzipLevel) - } - if gcs.FormatVersion != 2 { - t.Errorf("bad format_version: %q", gcs.FormatVersion) - } - if gcs.Format != "format" { - t.Errorf("bad format: %q", gcs.Format) - } - if gcs.TimestampFormat != "%Y" { - t.Errorf("bad timestamp_format: %q", gcs.TimestampFormat) - } - if gcs.MessageType != "blank" { - t.Errorf("bad message_type: %q", gcs.MessageType) - } - if gcs.Placement != "waf_debug" { - t.Errorf("bad placement: %q", gcs.Placement) - } - - // List - var gcses []*GCS - record(t, "gcses/list", func(c *Client) { - gcses, err = c.ListGCSs(&ListGCSsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(gcses) < 1 { - t.Errorf("bad gcses: %v", gcses) - } - - // Get - var ngcs *GCS - record(t, "gcses/get", func(c *Client) { - ngcs, err = c.GetGCS(&GetGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gcs", - }) - }) - if err != nil { - t.Fatal(err) - } - if gcs.Name != ngcs.Name { - t.Errorf("bad name: %q", gcs.Name) - } - if gcs.Bucket != ngcs.Bucket { - t.Errorf("bad bucket: %q", gcs.Bucket) - } - if gcs.User != ngcs.User { - t.Errorf("bad user: %q", gcs.User) - } - if gcs.SecretKey != ngcs.SecretKey { - t.Errorf("bad secret_key: %q", gcs.SecretKey) - } - if gcs.Path != ngcs.Path { - t.Errorf("bad path: %q", gcs.Path) - } - if gcs.Period != ngcs.Period { - t.Errorf("bad period: %q", gcs.Period) - } - if gcs.GzipLevel != ngcs.GzipLevel { - t.Errorf("bad gzip_level: %q", gcs.GzipLevel) - } - if gcs.FormatVersion != ngcs.FormatVersion { - t.Errorf("bad format_version: %q", gcs.FormatVersion) - } - if gcs.Format != ngcs.Format { - t.Errorf("bad format: %q", gcs.Format) - } - if gcs.TimestampFormat != ngcs.TimestampFormat { - t.Errorf("bad timestamp_format: %q", gcs.TimestampFormat) - } - if gcs.MessageType != ngcs.MessageType { - t.Errorf("bad message_type: %q", gcs.MessageType) - } - if gcs.Placement != ngcs.Placement { - t.Errorf("bad placement: %q", gcs.Placement) - } - - // Update - var ugcs *GCS - record(t, "gcses/update", func(c *Client) { - ugcs, err = c.UpdateGCS(&UpdateGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gcs", - NewName: "new-test-gcs", - }) - }) - if err != nil { - t.Fatal(err) - } - if ugcs.Name != "new-test-gcs" { - t.Errorf("bad name: %q", ugcs.Name) - } - - // Delete - record(t, "gcses/delete", func(c *Client) { - err = c.DeleteGCS(&DeleteGCSInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-gcs", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListGCSs_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/gzip_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/gzip_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/gzip_test.go 2019-08-22 13:47:49.750072885 +0000 @@ -3,146 +3,6 @@ import "testing" func TestClient_Gzips(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "gzips/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var gzip *Gzip - record(t, "gzips/create", func(c *Client) { - gzip, err = c.CreateGzip(&CreateGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip", - ContentTypes: "text/html text/css", - Extensions: "html css", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Create omissions (GH-7) - var gzipomit *Gzip - record(t, "gzips/create_omissions", func(c *Client) { - gzipomit, err = c.CreateGzip(&CreateGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip-omit", - }) - }) - if err != nil { - t.Fatal(err) - } - if gzipomit.ContentTypes != "" { - t.Errorf("bad content_types: %q", gzipomit.ContentTypes) - } - if gzipomit.Extensions != "" { - t.Errorf("bad extensions: %q", gzipomit.Extensions) - } - - // Ensure deleted - defer func() { - record(t, "gzips/cleanup", func(c *Client) { - c.DeleteGzip(&DeleteGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip", - }) - - c.DeleteGzip(&DeleteGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip-omit", - }) - - c.DeleteGzip(&DeleteGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-gzip", - }) - }) - }() - - if gzip.Name != "test-gzip" { - t.Errorf("bad name: %q", gzip.Name) - } - if gzip.ContentTypes != "text/html text/css" { - t.Errorf("bad content_types: %q", gzip.ContentTypes) - } - if gzip.Extensions != "html css" { - t.Errorf("bad extensions: %q", gzip.Extensions) - } - - // List - var gzips []*Gzip - record(t, "gzips/list", func(c *Client) { - gzips, err = c.ListGzips(&ListGzipsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(gzips) < 1 { - t.Errorf("bad gzips: %v", gzips) - } - - // Get - var ngzip *Gzip - record(t, "gzips/get", func(c *Client) { - ngzip, err = c.GetGzip(&GetGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip", - }) - }) - if err != nil { - t.Fatal(err) - } - if ngzip.Name != gzip.Name { - t.Errorf("bad name: %q", ngzip.Name) - } - if ngzip.ContentTypes != gzip.ContentTypes { - t.Errorf("bad content_types: %q", ngzip.ContentTypes) - } - if ngzip.Extensions != gzip.Extensions { - t.Errorf("bad extensions: %q", ngzip.Extensions) - } - - // Update - var ugzip *Gzip - record(t, "gzips/update", func(c *Client) { - ugzip, err = c.UpdateGzip(&UpdateGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-gzip", - NewName: "new-test-gzip", - }) - }) - if err != nil { - t.Fatal(err) - } - if ugzip.Name != "new-test-gzip" { - t.Errorf("bad name: %q", ugzip.Name) - } - - // Delete - record(t, "gzips/delete", func(c *Client) { - err = c.DeleteGzip(&DeleteGzipInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-gzip", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListGzips_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/header_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/header_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/header_test.go 2019-08-22 13:45:55.953012742 +0000 @@ -3,163 +3,6 @@ import "testing" func TestClient_Headers(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "headers/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var h *Header - record(t, "headers/create", func(c *Client) { - h, err = c.CreateHeader(&CreateHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-header", - Action: HeaderActionSet, - IgnoreIfSet: CBool(false), - Type: HeaderTypeRequest, - Destination: "http.foo", - Source: "client.ip", - Regex: "foobar", - Substitution: "123", - Priority: 50, - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "headers/cleanup", func(c *Client) { - c.DeleteHeader(&DeleteHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-header", - }) - - c.DeleteHeader(&DeleteHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-header", - }) - }) - }() - - if h.Name != "test-header" { - t.Errorf("bad name: %q", h.Name) - } - if h.Action != HeaderActionSet { - t.Errorf("bad header_action_set: %q", h.Action) - } - if h.IgnoreIfSet != false { - t.Errorf("bad ignore_if_set: %t", h.IgnoreIfSet) - } - if h.Type != HeaderTypeRequest { - t.Errorf("bad type: %q", h.Type) - } - if h.Destination != "http.foo" { - t.Errorf("bad destination: %q", h.Destination) - } - if h.Source != "client.ip" { - t.Errorf("bad source: %q", h.Source) - } - if h.Regex != "foobar" { - t.Errorf("bad regex: %q", h.Regex) - } - if h.Substitution != "123" { - t.Errorf("bad substitution: %q", h.Substitution) - } - if h.Priority != 50 { - t.Errorf("bad priority: %d", h.Priority) - } - - // List - var hs []*Header - record(t, "headers/list", func(c *Client) { - hs, err = c.ListHeaders(&ListHeadersInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(hs) < 1 { - t.Errorf("bad headers: %v", hs) - } - - // Get - var nh *Header - record(t, "headers/get", func(c *Client) { - nh, err = c.GetHeader(&GetHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-header", - }) - }) - if err != nil { - t.Fatal(err) - } - if h.Name != nh.Name { - t.Errorf("bad name: %q (%q)", h.Name, nh.Name) - } - if h.Action != nh.Action { - t.Errorf("bad header_action_set: %q", h.Action) - } - if h.IgnoreIfSet != nh.IgnoreIfSet { - t.Errorf("bad ignore_if_set: %t", h.IgnoreIfSet) - } - if h.Type != nh.Type { - t.Errorf("bad type: %q", h.Type) - } - if h.Destination != nh.Destination { - t.Errorf("bad destination: %q", h.Destination) - } - if h.Source != nh.Source { - t.Errorf("bad source: %q", h.Source) - } - if h.Regex != nh.Regex { - t.Errorf("bad regex: %q", h.Regex) - } - if h.Substitution != nh.Substitution { - t.Errorf("bad substitution: %q", h.Substitution) - } - if h.Priority != nh.Priority { - t.Errorf("bad priority: %d", h.Priority) - } - - // Update - var uh *Header - record(t, "headers/update", func(c *Client) { - uh, err = c.UpdateHeader(&UpdateHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-header", - NewName: "new-test-header", - }) - }) - if err != nil { - t.Fatal(err) - } - if uh.Name != "new-test-header" { - t.Errorf("bad name: %q", uh.Name) - } - - // Delete - record(t, "headers/delete", func(c *Client) { - err = c.DeleteHeader(&DeleteHeaderInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-header", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListHeaders_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/health_check_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/health_check_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/health_check_test.go 2019-08-22 13:47:10.792340579 +0000 @@ -3,177 +3,6 @@ import "testing" func TestClient_HealthChecks(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "health_checks/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var hc *HealthCheck - record(t, "health_checks/create", func(c *Client) { - hc, err = c.CreateHealthCheck(&CreateHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-healthcheck", - Method: "HEAD", - Host: "example.com", - Path: "/foo", - HTTPVersion: "1.1", - Timeout: 1500, - CheckInterval: 2500, - ExpectedResponse: 200, - Window: 5000, - Threshold: 10, - Initial: 10, - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "health_checks/cleanup", func(c *Client) { - c.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-healthcheck", - }) - - c.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-healthcheck", - }) - }) - }() - - if hc.Name != "test-healthcheck" { - t.Errorf("bad name: %q", hc.Name) - } - if hc.Method != "HEAD" { - t.Errorf("bad address: %q", hc.Method) - } - if hc.Host != "example.com" { - t.Errorf("bad host: %q", hc.Host) - } - if hc.Path != "/foo" { - t.Errorf("bad path: %q", hc.Path) - } - if hc.HTTPVersion != "1.1" { - t.Errorf("bad http_version: %q", hc.HTTPVersion) - } - if hc.Timeout != 1500 { - t.Errorf("bad timeout: %q", hc.Timeout) - } - if hc.CheckInterval != 2500 { - t.Errorf("bad check_interval: %q", hc.CheckInterval) - } - if hc.ExpectedResponse != 200 { - t.Errorf("bad timeout: %q", hc.ExpectedResponse) - } - if hc.Window != 5000 { - t.Errorf("bad window: %q", hc.Window) - } - if hc.Threshold != 10 { - t.Errorf("bad threshold: %q", hc.Threshold) - } - if hc.Initial != 10 { - t.Errorf("bad initial: %q", hc.Initial) - } - - // List - var hcs []*HealthCheck - record(t, "health_checks/list", func(c *Client) { - hcs, err = c.ListHealthChecks(&ListHealthChecksInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(hcs) < 1 { - t.Errorf("bad health checks: %v", hcs) - } - - // Get - var nhc *HealthCheck - record(t, "health_checks/get", func(c *Client) { - nhc, err = c.GetHealthCheck(&GetHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-healthcheck", - }) - }) - if err != nil { - t.Fatal(err) - } - if hc.Name != nhc.Name { - t.Errorf("bad name: %q (%q)", hc.Name, nhc.Name) - } - if hc.Method != nhc.Method { - t.Errorf("bad address: %q", hc.Method) - } - if hc.Host != nhc.Host { - t.Errorf("bad host: %q", hc.Host) - } - if hc.Path != nhc.Path { - t.Errorf("bad path: %q", hc.Path) - } - if hc.HTTPVersion != nhc.HTTPVersion { - t.Errorf("bad http_version: %q", hc.HTTPVersion) - } - if hc.Timeout != nhc.Timeout { - t.Errorf("bad timeout: %q", hc.Timeout) - } - if hc.CheckInterval != nhc.CheckInterval { - t.Errorf("bad check_interval: %q", hc.CheckInterval) - } - if hc.ExpectedResponse != nhc.ExpectedResponse { - t.Errorf("bad timeout: %q", hc.ExpectedResponse) - } - if hc.Window != nhc.Window { - t.Errorf("bad window: %q", hc.Window) - } - if hc.Threshold != nhc.Threshold { - t.Errorf("bad threshold: %q", hc.Threshold) - } - if hc.Initial != nhc.Initial { - t.Errorf("bad initial: %q", hc.Initial) - } - - // Update - var uhc *HealthCheck - record(t, "health_checks/update", func(c *Client) { - uhc, err = c.UpdateHealthCheck(&UpdateHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-healthcheck", - NewName: "new-test-healthcheck", - }) - }) - if err != nil { - t.Fatal(err) - } - if uhc.Name != "new-test-healthcheck" { - t.Errorf("bad name: %q", uhc.Name) - } - - // Delete - record(t, "health_checks/delete", func(c *Client) { - err = c.DeleteHealthCheck(&DeleteHealthCheckInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-healthcheck", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListHealthChecks_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/logentries_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/logentries_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/logentries_test.go 2019-08-22 13:46:32.322629967 +0000 @@ -3,152 +3,6 @@ import "testing" func TestClient_Logentries(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "logentries/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var le *Logentries - record(t, "logentries/create", func(c *Client) { - le, err = c.CreateLogentries(&CreateLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logentries", - Port: 1234, - UseTLS: CBool(true), - Token: "abcd1234", - Format: "format", - Placement: "waf_debug", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "logentries/delete", func(c *Client) { - c.DeleteLogentries(&DeleteLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logentries", - }) - - c.DeleteLogentries(&DeleteLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-logentries", - }) - }) - }() - - if le.Name != "test-logentries" { - t.Errorf("bad name: %q", le.Name) - } - if le.Port != 1234 { - t.Errorf("bad port: %q", le.Port) - } - if le.UseTLS != true { - t.Errorf("bad use_tls: %t", le.UseTLS) - } - if le.Token != "abcd1234" { - t.Errorf("bad token: %q", le.Token) - } - if le.Format != "format" { - t.Errorf("bad format: %q", le.Format) - } - if le.FormatVersion != 2 { - t.Errorf("bad format_version: %q", le.FormatVersion) - } - if le.Placement != "waf_debug" { - t.Errorf("bad placement: %q", le.Placement) - } - - // List - var les []*Logentries - record(t, "logentries/list", func(c *Client) { - les, err = c.ListLogentries(&ListLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(les) < 1 { - t.Errorf("bad logentriess: %v", les) - } - - // Get - var nle *Logentries - record(t, "logentries/get", func(c *Client) { - nle, err = c.GetLogentries(&GetLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logentries", - }) - }) - if err != nil { - t.Fatal(err) - } - if le.Name != nle.Name { - t.Errorf("bad name: %q", le.Name) - } - if le.Port != nle.Port { - t.Errorf("bad port: %q", le.Port) - } - if le.UseTLS != nle.UseTLS { - t.Errorf("bad use_tls: %t", le.UseTLS) - } - if le.Token != nle.Token { - t.Errorf("bad token: %q", le.Token) - } - if le.Format != nle.Format { - t.Errorf("bad format: %q", le.Format) - } - if le.FormatVersion != nle.FormatVersion { - t.Errorf("bad format_version: %q", le.FormatVersion) - } - if le.Placement != nle.Placement { - t.Errorf("bad placement: %q", le.Placement) - } - - // Update - var ule *Logentries - record(t, "logentries/update", func(c *Client) { - ule, err = c.UpdateLogentries(&UpdateLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-logentries", - NewName: "new-test-logentries", - FormatVersion: 2, - }) - }) - if err != nil { - t.Fatal(err) - } - if ule.Name != "new-test-logentries" { - t.Errorf("bad name: %q", ule.Name) - } - if ule.FormatVersion != 2 { - t.Errorf("bad format_version: %q", ule.FormatVersion) - } - - // Delete - record(t, "logentries/delete", func(c *Client) { - err = c.DeleteLogentries(&DeleteLogentriesInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-logentries", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListLogentries_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/purge_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/purge_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/purge_test.go 2019-08-22 13:43:56.551703395 +0000 @@ -3,24 +3,4 @@ import "testing" func TestClient_Purge(t *testing.T) { - t.Parallel() - - var err error - var purge *Purge - record(t, "purges/purge_by_key", func(c *Client) { - purge, err = c.PurgeKey(&PurgeKeyInput{ - Service: testServiceID, - Key: "foo", - }) - }) - if err != nil { - t.Fatal(err) - } - - if purge.Status != "ok" { - t.Error("bad status") - } - if len(purge.ID) == 0 { - t.Error("bad id") - } } Index: golang-github-sethvargo-go-fastly/fastly/service_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/service_test.go 2019-08-21 23:08:10.889972644 +0000 +++ golang-github-sethvargo-go-fastly/fastly/service_test.go 2019-08-22 13:45:22.039504728 +0000 @@ -3,159 +3,6 @@ import "testing" func TestClient_Services(t *testing.T) { - t.Parallel() - - var err error - - // Create - var s *Service - record(t, "services/create", func(c *Client) { - s, err = c.CreateService(&CreateServiceInput{ - Name: "test-service", - Comment: "comment", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "services/cleanup", func(c *Client) { - c.DeleteService(&DeleteServiceInput{ - ID: s.ID, - }) - - c.DeleteService(&DeleteServiceInput{ - ID: s.ID, - }) - }) - }() - - if s.Name != "test-service" { - t.Errorf("bad name: %q", s.Name) - } - if s.Comment != "comment" { - t.Errorf("bad comment: %q", s.Comment) - } - - // List - var ss []*Service - record(t, "services/list", func(c *Client) { - ss, err = c.ListServices(&ListServicesInput{}) - }) - if err != nil { - t.Fatal(err) - } - if len(ss) < 1 { - t.Errorf("bad services: %v", ss) - } - - // Get - var ns *Service - record(t, "services/get", func(c *Client) { - ns, err = c.GetService(&GetServiceInput{ - ID: s.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - if s.Name != ns.Name { - t.Errorf("bad name: %q (%q)", s.Name, ns.Name) - } - if s.Comment != ns.Comment { - t.Errorf("bad comment: %q (%q)", s.Comment, ns.Comment) - } - - if ns.CreatedAt == nil { - t.Errorf("Bad created at: empty") - } - - if ns.UpdatedAt == nil { - t.Errorf("Bad updated at: empty") - } - - if ns.DeletedAt != nil { - t.Errorf("Bad deleted at: %s", ns.DeletedAt) - } - - // Get Details - var nsd *ServiceDetail - record(t, "services/details", func(c *Client) { - nsd, err = c.GetServiceDetails(&GetServiceInput{ - ID: s.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - if s.Name != nsd.Name { - t.Errorf("bad name: %q (%q)", s.Name, nsd.Name) - } - if s.Comment != nsd.Comment { - t.Errorf("bad comment: %q (%q)", s.Comment, nsd.Comment) - } - if nsd.Version.Number == 0 { - t.Errorf("Service Detail Version is empty: (%#v)", nsd) - } - - // Search - var fs *Service - record(t, "services/search", func(c *Client) { - fs, err = c.SearchService(&SearchServiceInput{ - Name: "test-service", - }) - }) - if err != nil { - t.Fatal(err) - } - if s.Name != fs.Name { - t.Errorf("bad name: %q (%q)", s.Name, fs.Name) - } - if s.Comment != fs.Comment { - t.Errorf("bad comment: %q (%q)", s.Comment, fs.Comment) - } - - // Update - var us *Service - record(t, "services/update", func(c *Client) { - us, err = c.UpdateService(&UpdateServiceInput{ - ID: s.ID, - Name: "new-test-service", - }) - }) - if err != nil { - t.Fatal(err) - } - if us.Name != "new-test-service" { - t.Errorf("bad name: %q", us.Name) - } - - // Delete - record(t, "services/delete", func(c *Client) { - err = c.DeleteService(&DeleteServiceInput{ - ID: s.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - - // List Domains - var ds ServiceDomainsList - record(t, "services/domain", func(c *Client) { - ds, err = c.ListServiceDomains(&ListServiceDomainInput{ - ID: s.ID, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ds) != 0 { - t.Fatalf("bad services: %v", ds) - } } func TestClient_GetService_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/cache_setting_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/cache_setting_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/cache_setting_test.go 2019-08-22 14:07:38.158917139 +0000 @@ -3,128 +3,6 @@ import "testing" func TestClient_CacheSettings(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "cache_settings/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var cacheSetting *CacheSetting - record(t, "cache_settings/create", func(c *Client) { - cacheSetting, err = c.CreateCacheSetting(&CreateCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cache-setting", - Action: CacheSettingActionCache, - TTL: 1234, - StaleTTL: 1500, - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "cache_settings/cleanup", func(c *Client) { - c.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cache-setting", - }) - - c.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-cache-setting", - }) - }) - }() - - if cacheSetting.Name != "test-cache-setting" { - t.Errorf("bad name: %q", cacheSetting.Name) - } - if cacheSetting.Action != CacheSettingActionCache { - t.Errorf("bad action: %q", cacheSetting.Action) - } - if cacheSetting.TTL != 1234 { - t.Errorf("bad ttl: %d", cacheSetting.TTL) - } - if cacheSetting.StaleTTL != 1500 { - t.Errorf("bad stale_ttl: %d", cacheSetting.StaleTTL) - } - - // List - var cacheSettings []*CacheSetting - record(t, "cache_settings/list", func(c *Client) { - cacheSettings, err = c.ListCacheSettings(&ListCacheSettingsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(cacheSettings) < 1 { - t.Errorf("bad cache settings: %v", cacheSettings) - } - - // Get - var newCacheSetting *CacheSetting - record(t, "cache_settings/get", func(c *Client) { - newCacheSetting, err = c.GetCacheSetting(&GetCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cache-setting", - }) - }) - if err != nil { - t.Fatal(err) - } - if cacheSetting.Name != newCacheSetting.Name { - t.Errorf("bad name: %q (%q)", cacheSetting.Name, newCacheSetting.Name) - } - if cacheSetting.Action != CacheSettingActionCache { - t.Errorf("bad action: %q", cacheSetting.Action) - } - if cacheSetting.TTL != 1234 { - t.Errorf("bad ttl: %d", cacheSetting.TTL) - } - if cacheSetting.StaleTTL != 1500 { - t.Errorf("bad stale_ttl: %d", cacheSetting.StaleTTL) - } - - // Update - var updatedCacheSetting *CacheSetting - record(t, "cache_settings/update", func(c *Client) { - updatedCacheSetting, err = c.UpdateCacheSetting(&UpdateCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-cache-setting", - NewName: "new-test-cache-setting", - }) - }) - if err != nil { - t.Fatal(err) - } - if updatedCacheSetting.Name != "new-test-cache-setting" { - t.Errorf("bad name: %q", updatedCacheSetting.Name) - } - - // Delete - record(t, "cache_settings/delete", func(c *Client) { - err = c.DeleteCacheSetting(&DeleteCacheSettingInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-cache-setting", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListCacheSettings_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/condition_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/condition_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/condition_test.go 2019-08-22 14:11:55.578363666 +0000 @@ -3,122 +3,6 @@ import "testing" func TestClient_Conditions(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "conditions/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var condition *Condition - record(t, "conditions/create", func(c *Client) { - condition, err = c.CreateCondition(&CreateConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", - Statement: "req.url~+\"index.html\"", - Type: "REQUEST", - Priority: 1, - }) - }) - if err != nil { - t.Fatal(err) - } - - // // Ensure deleted - defer func() { - record(t, "conditions/cleanup", func(c *Client) { - c.DeleteCondition(&DeleteConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", - }) - }) - }() - - if condition.Name != "test/condition" { - t.Errorf("bad name: %q", condition.Name) - } - if condition.Statement != "req.url~+\"index.html\"" { - t.Errorf("bad statement: %q", condition.Statement) - } - if condition.Type != "REQUEST" { - t.Errorf("bad type: %s", condition.Type) - } - if condition.Priority != 1 { - t.Errorf("bad priority: %d", condition.Priority) - } - - // List - var conditions []*Condition - record(t, "conditions/list", func(c *Client) { - conditions, err = c.ListConditions(&ListConditionsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(conditions) < 1 { - t.Errorf("bad conditions: %v", conditions) - } - - // Get - var newCondition *Condition - record(t, "conditions/get", func(c *Client) { - newCondition, err = c.GetCondition(&GetConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", - }) - }) - if err != nil { - t.Fatal(err) - } - if condition.Name != newCondition.Name { - t.Errorf("bad name: %q (%q)", condition.Name, newCondition.Name) - } - if condition.Statement != "req.url~+\"index.html\"" { - t.Errorf("bad statement: %q", condition.Statement) - } - if condition.Type != "REQUEST" { - t.Errorf("bad type: %s", condition.Type) - } - if condition.Priority != 1 { - t.Errorf("bad priority: %d", condition.Priority) - } - - // Update - var updatedCondition *Condition - record(t, "conditions/update", func(c *Client) { - updatedCondition, err = c.UpdateCondition(&UpdateConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", - Statement: "req.url~+\"updated.html\"", - }) - }) - if err != nil { - t.Fatal(err) - } - if updatedCondition.Statement != "req.url~+\"updated.html\"" { - t.Errorf("bad statement: %q", updatedCondition.Statement) - } - - // Delete - record(t, "conditions/delete", func(c *Client) { - err = c.DeleteCondition(&DeleteConditionInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test/condition", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListConditions_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/content_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/content_test.go 2019-08-21 23:08:10.829969976 +0000 +++ golang-github-sethvargo-go-fastly/fastly/content_test.go 2019-08-22 14:10:08.101584560 +0000 @@ -3,19 +3,4 @@ import "testing" func TestClient_EdgeCheck(t *testing.T) { - t.Parallel() - - var err error - var edges []*EdgeCheck - record(t, "content/check", func(c *Client) { - edges, err = c.EdgeCheck(&EdgeCheckInput{ - URL: "releases.hashicorp.com", - }) - }) - if err != nil { - t.Fatal(err) - } - if len(edges) < 1 { - t.Errorf("bad edge check: %d", len(edges)) - } } Index: golang-github-sethvargo-go-fastly/fastly/dictionary_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/dictionary_test.go 2019-08-21 23:08:10.833970154 +0000 +++ golang-github-sethvargo-go-fastly/fastly/dictionary_test.go 2019-08-22 14:11:21.996870414 +0000 @@ -3,106 +3,6 @@ import "testing" func TestClient_Dictionaries(t *testing.T) { - t.Parallel() - - fixtureBase := "dictionaries/" - - testVersion := createTestVersion(t, fixtureBase+"version", testServiceID) - - // Create - var err error - var d *Dictionary - record(t, fixtureBase+"create", func(c *Client) { - d, err = c.CreateDictionary(&CreateDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_dictionary", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, fixtureBase+"cleanup", func(c *Client) { - c.DeleteDictionary(&DeleteDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_dictionary", - }) - - c.DeleteDictionary(&DeleteDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "new_test_dictionary", - }) - }) - }() - - if d.Name != "test_dictionary" { - t.Errorf("bad name: %q", d.Name) - } - - // List - var ds []*Dictionary - record(t, fixtureBase+"list", func(c *Client) { - ds, err = c.ListDictionaries(&ListDictionariesInput{ - Service: testServiceID, - Version: testVersion.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ds) < 1 { - t.Errorf("bad dictionaries: %v", ds) - } - - // Get - var nd *Dictionary - record(t, fixtureBase+"get", func(c *Client) { - nd, err = c.GetDictionary(&GetDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_dictionary", - }) - }) - if err != nil { - t.Fatal(err) - } - if d.Name != nd.Name { - t.Errorf("bad name: %q (%q)", d.Name, nd.Name) - } - - // Update - var ud *Dictionary - record(t, fixtureBase+"update", func(c *Client) { - ud, err = c.UpdateDictionary(&UpdateDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "test_dictionary", - NewName: "new_test_dictionary", - }) - }) - if err != nil { - t.Fatal(err) - } - if ud.Name != "new_test_dictionary" { - t.Errorf("bad name: %q", ud.Name) - } - - // Delete - record(t, fixtureBase+"delete", func(c *Client) { - err = c.DeleteDictionary(&DeleteDictionaryInput{ - Service: testServiceID, - Version: testVersion.Number, - Name: "new_test_dictionary", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListDictionaries_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/diff_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/diff_test.go 2019-08-21 23:08:10.833970154 +0000 +++ golang-github-sethvargo-go-fastly/fastly/diff_test.go 2019-08-22 14:10:51.163499360 +0000 @@ -3,70 +3,6 @@ import "testing" func TestClient_Diff(t *testing.T) { - t.Parallel() - - var err error - var tv1 *Version - record(t, "diff/version_1", func(c *Client) { - tv1 = testVersion(t, c) - }) - - var tv2 *Version - record(t, "diff/version_2", func(c *Client) { - tv2 = testVersion(t, c) - }) - - // Diff should be empty - var d *Diff - record(t, "diff/get", func(c *Client) { - d, err = c.GetDiff(&GetDiffInput{ - Service: testServiceID, - From: tv1.Number, - To: tv2.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - - // Create a diff - record(t, "diff/create_backend", func(c *Client) { - _, err = c.CreateBackend(&CreateBackendInput{ - Service: testServiceID, - Version: tv2.Number, - Name: "test-backend", - Address: "integ-test.go-fastly.com", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure we delete the backend we just created - defer func() { - record(t, "diff/cleanup", func(c *Client) { - c.DeleteBackend(&DeleteBackendInput{ - Service: testServiceID, - Version: tv2.Number, - Name: "test-backend", - }) - }) - }() - - // Diff should mot be empty - record(t, "diff/get_again", func(c *Client) { - d, err = c.GetDiff(&GetDiffInput{ - Service: testServiceID, - From: tv1.Number, - To: tv2.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(d.Diff) == 0 { - t.Errorf("bad diff: %s", d.Diff) - } } func TestClient_Diff_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/director_backend_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/director_backend_test.go 2019-08-21 23:08:10.833970154 +0000 +++ golang-github-sethvargo-go-fastly/fastly/director_backend_test.go 2019-08-22 14:08:13.936508044 +0000 @@ -3,80 +3,6 @@ import "testing" func TestClient_DirectorBackends(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "director_backends/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var b *DirectorBackend - record(t, "director_backends/create", func(c *Client) { - b, err = c.CreateDirectorBackend(&CreateDirectorBackendInput{ - Service: testServiceID, - Version: tv.Number, - Director: "director", - Backend: "backend", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "director_backends/cleanup", func(c *Client) { - c.DeleteDirectorBackend(&DeleteDirectorBackendInput{ - Service: testServiceID, - Version: tv.Number, - Director: "director", - Backend: "backend", - }) - }) - }() - - if b.Director != "director" { - t.Errorf("bad director: %q", b.Director) - } - if b.Backend != "backend" { - t.Errorf("bad backend: %q", b.Backend) - } - - // Get - var nb *DirectorBackend - record(t, "director_backends/get", func(c *Client) { - nb, err = c.GetDirectorBackend(&GetDirectorBackendInput{ - Service: testServiceID, - Version: tv.Number, - Director: "director", - Backend: "backend", - }) - }) - if err != nil { - t.Fatal(err) - } - - if b.Director != nb.Director { - t.Errorf("bad director: %q", b.Director) - } - if b.Backend != nb.Backend { - t.Errorf("bad backend: %q", b.Backend) - } - - // Delete - record(t, "director_backends/delete", func(c *Client) { - err = c.DeleteDirectorBackend(&DeleteDirectorBackendInput{ - Service: testServiceID, - Version: tv.Number, - Director: "director", - Backend: "backend", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_CreateDirectorBackend_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/domain_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/domain_test.go 2019-08-21 23:08:10.833970154 +0000 +++ golang-github-sethvargo-go-fastly/fastly/domain_test.go 2019-08-22 14:09:40.336349932 +0000 @@ -3,114 +3,6 @@ import "testing" func TestClient_Domains(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "domains/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var d *Domain - record(t, "domains/create", func(c *Client) { - d, err = c.CreateDomain(&CreateDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "integ-test.go-fastly.com", - Comment: "comment", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "domains/cleanup", func(c *Client) { - c.DeleteDomain(&DeleteDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "integ-test.go-fastly.com", - }) - - c.DeleteDomain(&DeleteDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-integ-test.go-fastly.com", - }) - }) - }() - - if d.Name != "integ-test.go-fastly.com" { - t.Errorf("bad name: %q", d.Name) - } - if d.Comment != "comment" { - t.Errorf("bad comment: %q", d.Comment) - } - - // List - var ds []*Domain - record(t, "domains/list", func(c *Client) { - ds, err = c.ListDomains(&ListDomainsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ds) < 1 { - t.Errorf("bad domains: %v", ds) - } - - // Get - var nd *Domain - record(t, "domains/get", func(c *Client) { - nd, err = c.GetDomain(&GetDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "integ-test.go-fastly.com", - }) - }) - if err != nil { - t.Fatal(err) - } - if d.Name != nd.Name { - t.Errorf("bad name: %q (%q)", d.Name, nd.Name) - } - if d.Comment != nd.Comment { - t.Errorf("bad comment: %q (%q)", d.Comment, nd.Comment) - } - - // Update - var ud *Domain - record(t, "domains/update", func(c *Client) { - ud, err = c.UpdateDomain(&UpdateDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "integ-test.go-fastly.com", - NewName: "new-integ-test.go-fastly.com", - }) - }) - if err != nil { - t.Fatal(err) - } - if ud.Name != "new-integ-test.go-fastly.com" { - t.Errorf("bad name: %q", ud.Name) - } - - // Delete - record(t, "domains/delete", func(c *Client) { - err = c.DeleteDomain(&DeleteDomainInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-integ-test.go-fastly.com", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListDomains_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/ftp_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/ftp_test.go 2019-08-21 23:08:10.885972466 +0000 +++ golang-github-sethvargo-go-fastly/fastly/ftp_test.go 2019-08-22 14:09:12.415108372 +0000 @@ -3,184 +3,6 @@ import "testing" func TestClient_FTPs(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "ftps/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var ftp *FTP - record(t, "ftps/create", func(c *Client) { - ftp, err = c.CreateFTP(&CreateFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-ftp", - Address: "example.com", - Port: 1234, - Username: "username", - Password: "password", - Path: "/dir", - Period: 12, - GzipLevel: 9, - FormatVersion: 2, - Format: "format", - TimestampFormat: "%Y", - Placement: "waf_debug", - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "ftps/cleanup", func(c *Client) { - c.DeleteFTP(&DeleteFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-ftp", - }) - - c.DeleteFTP(&DeleteFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-ftp", - }) - }) - }() - - if ftp.Name != "test-ftp" { - t.Errorf("bad name: %q", ftp.Name) - } - if ftp.Address != "example.com" { - t.Errorf("bad address: %q", ftp.Address) - } - if ftp.Port != 1234 { - t.Errorf("bad port: %q", ftp.Port) - } - if ftp.Username != "username" { - t.Errorf("bad username: %q", ftp.Username) - } - if ftp.Password != "password" { - t.Errorf("bad password: %q", ftp.Password) - } - if ftp.Path != "/dir" { - t.Errorf("bad path: %q", ftp.Path) - } - if ftp.Period != 12 { - t.Errorf("bad period: %q", ftp.Period) - } - if ftp.GzipLevel != 9 { - t.Errorf("bad gzip_level: %q", ftp.GzipLevel) - } - if ftp.FormatVersion != 2 { - t.Errorf("bad format_version: %q", ftp.FormatVersion) - } - if ftp.Format != "format" { - t.Errorf("bad format: %q", ftp.Format) - } - if ftp.TimestampFormat != "%Y" { - t.Errorf("bad timestamp_format: %q", ftp.TimestampFormat) - } - if ftp.Placement != "waf_debug" { - t.Errorf("bad placement: %q", ftp.Placement) - } - - // List - var ftps []*FTP - record(t, "ftps/list", func(c *Client) { - ftps, err = c.ListFTPs(&ListFTPsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(ftps) < 1 { - t.Errorf("bad ftps: %v", ftps) - } - - // Get - var nftp *FTP - record(t, "ftps/get", func(c *Client) { - nftp, err = c.GetFTP(&GetFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-ftp", - }) - }) - if err != nil { - t.Fatal(err) - } - if ftp.Name != nftp.Name { - t.Errorf("bad name: %q", ftp.Name) - } - if ftp.Address != nftp.Address { - t.Errorf("bad address: %q", ftp.Address) - } - if ftp.Port != nftp.Port { - t.Errorf("bad port: %q", ftp.Port) - } - if ftp.Username != nftp.Username { - t.Errorf("bad username: %q", ftp.Username) - } - if ftp.Password != nftp.Password { - t.Errorf("bad password: %q", ftp.Password) - } - if ftp.Path != nftp.Path { - t.Errorf("bad path: %q", ftp.Path) - } - if ftp.Period != nftp.Period { - t.Errorf("bad period: %q", ftp.Period) - } - if ftp.GzipLevel != nftp.GzipLevel { - t.Errorf("bad gzip_level: %q", ftp.GzipLevel) - } - if ftp.FormatVersion != nftp.FormatVersion { - t.Errorf("bad format_version: %q", ftp.FormatVersion) - } - if ftp.Format != nftp.Format { - t.Errorf("bad format: %q", ftp.Format) - } - if ftp.TimestampFormat != nftp.TimestampFormat { - t.Errorf("bad timestamp_format: %q", ftp.TimestampFormat) - } - if ftp.Placement != nftp.Placement { - t.Errorf("bad placement: %q", ftp.Placement) - } - - // Update - var uftp *FTP - record(t, "ftps/update", func(c *Client) { - uftp, err = c.UpdateFTP(&UpdateFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-ftp", - NewName: "new-test-ftp", - }) - }) - if err != nil { - t.Fatal(err) - } - if uftp.Name != "new-test-ftp" { - t.Errorf("bad name: %q", uftp.Name) - } - - // Delete - record(t, "ftps/delete", func(c *Client) { - err = c.DeleteFTP(&DeleteFTPInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-ftp", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListFTPs_validation(t *testing.T) { Index: golang-github-sethvargo-go-fastly/fastly/director_test.go =================================================================== --- golang-github-sethvargo-go-fastly.orig/fastly/director_test.go 2019-08-21 23:08:10.833970154 +0000 +++ golang-github-sethvargo-go-fastly/fastly/director_test.go 2019-08-22 14:15:26.167727828 +0000 @@ -3,129 +3,6 @@ import "testing" func TestClient_Directors(t *testing.T) { - t.Parallel() - - var err error - var tv *Version - record(t, "directors/version", func(c *Client) { - tv = testVersion(t, c) - }) - - // Create - var b *Director - record(t, "directors/create", func(c *Client) { - b, err = c.CreateDirector(&CreateDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", - Quorum: 50, - Type: DirectorTypeRandom, - Retries: 5, - }) - }) - if err != nil { - t.Fatal(err) - } - - // Ensure deleted - defer func() { - record(t, "directors/cleanup", func(c *Client) { - c.DeleteDirector(&DeleteDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", - }) - - c.DeleteDirector(&DeleteDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "new-test-director", - }) - }) - }() - - if b.Name != "test-director" { - t.Errorf("bad name: %q", b.Name) - } - if b.Quorum != 50 { - t.Errorf("bad quorum: %q", b.Quorum) - } - if b.Type != DirectorTypeRandom { - t.Errorf("bad type: %d", b.Type) - } - if b.Retries != 5 { - t.Errorf("bad retries: %d", b.Retries) - } - - // List - var bs []*Director - record(t, "directors/list", func(c *Client) { - bs, err = c.ListDirectors(&ListDirectorsInput{ - Service: testServiceID, - Version: tv.Number, - }) - }) - if err != nil { - t.Fatal(err) - } - if len(bs) < 1 { - t.Errorf("bad directors: %v", bs) - } - - // Get - var nb *Director - record(t, "directors/get", func(c *Client) { - nb, err = c.GetDirector(&GetDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", - }) - }) - if err != nil { - t.Fatal(err) - } - if b.Name != nb.Name { - t.Errorf("bad name: %q (%q)", b.Name, nb.Name) - } - if b.Quorum != nb.Quorum { - t.Errorf("bad quorum: %q (%q)", b.Quorum, nb.Quorum) - } - if b.Type != nb.Type { - t.Errorf("bad type: %q (%q)", b.Type, nb.Type) - } - if b.Retries != nb.Retries { - t.Errorf("bad retries: %q (%q)", b.Retries, nb.Retries) - } - - // Update - var ub *Director - record(t, "directors/update", func(c *Client) { - ub, err = c.UpdateDirector(&UpdateDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", - NewName: "new-test-director", - Quorum: 100, - }) - }) - if err != nil { - t.Fatal(err) - } - if ub.Quorum != 100 { - t.Errorf("bad quorum: %q", ub.Quorum) - } - - // Delete - record(t, "directors/delete", func(c *Client) { - err = c.DeleteDirector(&DeleteDirectorInput{ - Service: testServiceID, - Version: tv.Number, - Name: "test-director", - }) - }) - if err != nil { - t.Fatal(err) - } } func TestClient_ListDirectors_validation(t *testing.T) {