Skip to content

Commit

Permalink
Add fields to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SharaevN committed Mar 3, 2022
1 parent 6a47a69 commit 4f8bcfa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"encoding/json"
"net/http"
"reflect"
"testing"
Expand All @@ -27,9 +28,16 @@ func TestTagsService_ListTags(t *testing.T) {
mux, server, client := setup(t)
defer teardown(server)

tagsJson := `[{"name": "1.0.0", "message": "test", "target": "fffff", "protected": false},{"name": "1.0.1"}]`
var want []*Tag
err := json.Unmarshal([]byte(tagsJson), &want)
if err != nil {
t.Errorf("Error occured during unmarshaling: %v", err)
}

mux.HandleFunc("/api/v4/projects/1/repository/tags", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `[{"name": "1.0.0"},{"name": "1.0.1"}]`)
fmt.Fprint(w, tagsJson)
})

opt := &ListTagsOptions{ListOptions: ListOptions{Page: 2, PerPage: 3}}
Expand All @@ -39,7 +47,6 @@ func TestTagsService_ListTags(t *testing.T) {
t.Errorf("Tags.ListTags returned error: %v", err)
}

want := []*Tag{{Name: "1.0.0"}, {Name: "1.0.1"}}
if !reflect.DeepEqual(want, tags) {
t.Errorf("Tags.ListTags returned %+v, want %+v", tags, want)
}
Expand Down

0 comments on commit 4f8bcfa

Please sign in to comment.