<commit_before>//
// Copyright 2021, <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package gitlab

import (
	"fmt"
	"encoding/json"
	"net/http"
	"reflect"
	"testing"
)

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, tagsJson)
	})

	opt := &ListTagsOptions{ListOptions: ListOptions{Page: 2, PerPage: 3}}

	tags, _, err := client.Tags.ListTags(1, opt)
	if err != nil {
		t.Errorf("Tags.ListTags returned error: %v", err)
	}

	if !reflect.DeepEqual(want, tags) {
		t.Errorf("Tags.ListTags returned %+v, want %+v", tags, want)
	}
}

func TestTagsService_CreateReleaseNote(t *testing.T) {<commit_msg>Let keep the test in sync with other tests<commit_after>//
// Copyright 2021, <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package gitlab

import (
	"fmt"
	"net/http"
	"reflect"
	"testing"
)

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

	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",
        "message": "test",
        "target": "fffff",
        "protected": false
      },{
        "name": "1.0.1",
        "protected": true
      }
    ]`)
	})

	opt := &ListTagsOptions{ListOptions: ListOptions{Page: 2, PerPage: 3}}

	tags, _, err := client.Tags.ListTags(1, opt)
	if err != nil {
		t.Errorf("Tags.ListTags returned error: %v", err)
	}

	want := []*Tag{
		{
			Name:      "1.0.0",
			Message:   "test",
			Target:    "fffff",
			Protected: false,
		},
		{
			Name:      "1.0.1",
			Protected: true,
		},
	}
	if !reflect.DeepEqual(want, tags) {
		t.Errorf("Tags.ListTags returned %+v, want %+v", tags, want)
	}
}

func TestTagsService_CreateReleaseNote(t *testing.T) {
{'fraction_non_alphanumeric': 0.1508857666463042, 'fraction_numerical': 0.013439218081857055, 'mean_word_length': 3.4078061911170927, 'pattern_counts': {'":': 11, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5164183', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1089, 'n_words': 337}