|
| 1 | +// +build integration |
| 2 | + |
| 3 | +package gapi |
| 4 | + |
| 5 | +import ( |
| 6 | + "fmt" |
| 7 | + "net/url" |
| 8 | + "testing" |
| 9 | +) |
| 10 | + |
| 11 | +func TestAnnotationsIntegration(t *testing.T) { |
| 12 | + client, err := New("admin:admin", "http://localhost:3000") |
| 13 | + if err != nil { |
| 14 | + t.Error(err) |
| 15 | + } |
| 16 | + |
| 17 | + _, err = client.Annotations(url.Values{}) |
| 18 | + if err != nil { |
| 19 | + t.Error(err) |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +func TestNewAnnotationIntegration(t *testing.T) { |
| 24 | + client, err := New("admin:admin", "http://localhost:3000") |
| 25 | + if err != nil { |
| 26 | + t.Error(err) |
| 27 | + } |
| 28 | + |
| 29 | + _, err = client.NewAnnotation(&Annotation{ |
| 30 | + Text: "integration-test-new", |
| 31 | + }) |
| 32 | + if err != nil { |
| 33 | + t.Error(err) |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +func TestUpdateAnnotationIntegration(t *testing.T) { |
| 38 | + client, err := New("admin:admin", "http://localhost:3000") |
| 39 | + if err != nil { |
| 40 | + t.Error(err) |
| 41 | + } |
| 42 | + |
| 43 | + id, err := client.NewAnnotation(&Annotation{ |
| 44 | + Text: "integration-test-update", |
| 45 | + }) |
| 46 | + if err != nil { |
| 47 | + t.Error(err) |
| 48 | + } |
| 49 | + |
| 50 | + message, err := client.UpdateAnnotation(id, &Annotation{ |
| 51 | + Text: "integration-test-updated", |
| 52 | + }) |
| 53 | + if err != nil { |
| 54 | + t.Error(err) |
| 55 | + } |
| 56 | + |
| 57 | + expected := "Annotation updated" |
| 58 | + if message != expected { |
| 59 | + t.Error(fmt.Sprintf("expected UpdateAnnotation message to be %s; got %s", expected, message)) |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +func TestDeleteAnnotationIntegration(t *testing.T) { |
| 64 | + client, err := New("admin:admin", "http://localhost:3000") |
| 65 | + if err != nil { |
| 66 | + t.Error(err) |
| 67 | + } |
| 68 | + |
| 69 | + id, err := client.NewAnnotation(&Annotation{ |
| 70 | + Text: "integration-test-delete", |
| 71 | + }) |
| 72 | + if err != nil { |
| 73 | + t.Error(err) |
| 74 | + } |
| 75 | + |
| 76 | + message, err := client.DeleteAnnotation(id) |
| 77 | + if err != nil { |
| 78 | + t.Error(err) |
| 79 | + } |
| 80 | + |
| 81 | + expected := "Annotation deleted" |
| 82 | + if message != expected { |
| 83 | + t.Error(fmt.Sprintf("expected DeleteAnnotation message to be %s; got %s", expected, message)) |
| 84 | + } |
| 85 | +} |
0 commit comments