| 1 | package slb |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/denverdino/aliyungo/common" |
| 8 | ) |
| 9 | |
| 10 | func TestAddTags(t *testing.T) { |
| 11 | client := NewTestClientForDebug() |
| 12 | |
| 13 | tagItemArr := []TagItem{ |
| 14 | TagItem{TagKey: "username", TagValue: "test"}, |
| 15 | TagItem{TagKey: "birdthday", TagValue: "20170101"}, |
| 16 | } |
| 17 | tagItems, _ := json.Marshal(tagItemArr) |
| 18 | |
| 19 | args := &AddTagsArgs{ |
| 20 | RegionId: common.Beijing, |
| 21 | LoadBalancerID: TestLoadBlancerID, |
| 22 | Tags: string(tagItems), |
| 23 | } |
| 24 | |
| 25 | err := client.AddTags(args) |
| 26 | if err != nil { |
| 27 | t.Fatalf("Failed to add tags %++v", err) |
| 28 | } |
| 29 | |
| 30 | t.Logf("Successfully to add tags") |
| 31 | } |
| 32 | |
| 33 | func TestRemoveTags(t *testing.T) { |
| 34 | client := NewTestClientForDebug() |
| 35 | |
| 36 | tagItemArr := []TagItem{ |
| 37 | TagItem{TagKey: "username", TagValue: "test"}, |
| 38 | TagItem{TagKey: "birdthday", TagValue: "20170101"}, |
| 39 | } |
| 40 | tagItems, _ := json.Marshal(tagItemArr) |
| 41 | |
| 42 | args := &RemoveTagsArgs{ |
| 43 | RegionId: common.Beijing, |
| 44 | LoadBalancerID: TestLoadBlancerID, |
| 45 | Tags: string(tagItems), |
| 46 | } |
| 47 | |
| 48 | err := client.RemoveTags(args) |
| 49 | if err != nil { |
| 50 | t.Fatalf("Failed to remove tags %++v", err) |
| 51 | } |
| 52 | |
| 53 | t.Logf("Successfully to remove tags") |
| 54 | } |
| 55 | |
| 56 | func TestDescribeTags(t *testing.T) { |
| 57 | client := NewTestClientForDebug() |
| 58 | |
| 59 | args := &DescribeTagsArgs{ |
| 60 | RegionId: common.Beijing, |
| 61 | LoadBalancerID: TestLoadBlancerID, |
| 62 | } |
| 63 | |
| 64 | tags, _, err := client.DescribeTags(args) |
| 65 | if err != nil { |
| 66 | t.Fatalf("Failed to describe tags %++v", err) |
| 67 | } |
| 68 | |
| 69 | t.Logf("tags is %++v", tags) |
| 70 | } |