mirror of
https://github.com/documize/community.git
synced 2025-07-26 08:39:44 +02:00
initial commit
This commit is contained in:
commit
18933c6767
1841 changed files with 810642 additions and 0 deletions
64
vendor/github.com/google/go-github/github/licenses_test.go
generated
vendored
Normal file
64
vendor/github.com/google/go-github/github/licenses_test.go
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package github
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLicensesService_List(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/licenses", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testHeader(t, r, "Accept", mediaTypeLicensesPreview)
|
||||
fmt.Fprint(w, `[{"key":"mit","name":"MIT","url":"https://api.github.com/licenses/mit"}]`)
|
||||
})
|
||||
|
||||
licenses, _, err := client.Licenses.List()
|
||||
if err != nil {
|
||||
t.Errorf("Licenses.List returned error: %v", err)
|
||||
}
|
||||
|
||||
want := []*License{{
|
||||
Key: String("mit"),
|
||||
Name: String("MIT"),
|
||||
URL: String("https://api.github.com/licenses/mit"),
|
||||
}}
|
||||
if !reflect.DeepEqual(licenses, want) {
|
||||
t.Errorf("Licenses.List returned %+v, want %+v", licenses, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLicensesService_Get(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/licenses/mit", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testHeader(t, r, "Accept", mediaTypeLicensesPreview)
|
||||
fmt.Fprint(w, `{"key":"mit","name":"MIT"}`)
|
||||
})
|
||||
|
||||
license, _, err := client.Licenses.Get("mit")
|
||||
if err != nil {
|
||||
t.Errorf("Licenses.Get returned error: %v", err)
|
||||
}
|
||||
|
||||
want := &License{Key: String("mit"), Name: String("MIT")}
|
||||
if !reflect.DeepEqual(license, want) {
|
||||
t.Errorf("Licenses.Get returned %+v, want %+v", license, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLicensesService_Get_invalidTemplate(t *testing.T) {
|
||||
_, _, err := client.Licenses.Get("%")
|
||||
testURLParseError(t, err)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue