Import upstream version 1.1.0
Debian Janitor
2 years ago
0 | 0 | language: go |
1 | 1 | |
2 | go: | |
3 | - stable | |
4 | - "1.10.x" | |
2 | cache: | |
3 | directories: | |
4 | - $GOPATH/pkg/mod | |
5 | ||
6 | jobs: | |
7 | fast_finish: true | |
8 | include: | |
9 | - go: 1.12.x | |
10 | - go: 1.13.x | |
11 | - go: 1.14.x | |
12 | - go: 1.x | |
13 | - go: tip | |
14 | allow_failures: | |
15 | - go: tip | |
5 | 16 | |
6 | 17 | before_install: |
7 | - go get github.com/axw/gocov/gocov | |
8 | - go get github.com/mattn/goveralls | |
9 | - go get golang.org/x/lint/golint | |
10 | - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi | |
18 | - export GO111MODULE=off | |
19 | - go get github.com/axw/gocov/gocov | |
20 | - go get github.com/mattn/goveralls | |
21 | - go get golang.org/x/lint/golint | |
22 | - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi | |
23 | - GO111MODULE=on | |
24 | ||
25 | install: | |
26 | - go mod tidy | |
27 | - git diff --exit-code go.mod | |
28 | - git diff --exit-code go.sum | |
29 | - go mod download | |
11 | 30 | |
12 | 31 | script: |
13 | # Test Code quality | |
14 | - go vet ./... | |
15 | - ${GOPATH}/bin/golint ./... | |
16 | - go test -covermode=count -coverprofile=profile.cov ./... | |
32 | # Test Code quality | |
33 | - go vet ./... | |
34 | - ${GOPATH}/bin/golint ./... | |
35 | - go test -covermode=count -coverprofile=profile.cov ./... | |
17 | 36 | |
18 | # Test buildable on most common platforms, beyond Linux | |
19 | - GOOS=darwin go build ./... | |
20 | - GOOS=windows go build ./... | |
37 | # Test buildable on most common platforms, beyond Linux | |
38 | - GOOS=darwin go build ./... | |
39 | - GOOS=windows go build ./... | |
21 | 40 | |
22 | # Best effort: notify coveralls. It's too unstable, ignore errors. | |
23 | - $HOME/gopath/bin/goveralls -coverprofile=profile.cov -service=travis-ci || exit 0 | |
41 | # Best effort: notify coveralls. It's too unstable, ignore errors. | |
42 | - $HOME/gopath/bin/goveralls -coverprofile=profile.cov -service=travis-ci || exit 0 |
86 | 86 | * ``soyoustart-ca`` for So you Start Canada API |
87 | 87 | * ``kimsufi-eu`` for Kimsufi Europe API |
88 | 88 | * ``kimsufi-ca`` for Kimsufi Canada API |
89 | * ``runabove-ca`` for RunAbove API | |
90 | 89 | * Or any arbitrary URL to use in a test for example |
91 | 90 | |
92 | 91 | The client will successively attempt to locate this configuration file in |
499 | 498 | - **Create application credentials**: https://ca.api.kimsufi.com/createApp/ |
500 | 499 | - **Create script credentials** (all keys at once): https://ca.api.kimsufi.com/createToken/ |
501 | 500 | |
502 | ### Runabove | |
503 | ||
504 | - **Community support**: https://community.runabove.com/ | |
505 | - **Console**: https://api.runabove.com/console/ | |
506 | - **Create application credentials**: https://api.runabove.com/createApp/ | |
507 | - **High level SDK**: https://github.com/runabove/python-runabove | |
508 | ||
509 | 501 | ## License |
510 | 502 | |
511 | 503 | 3-Clause BSD |
512 |
0 | module github.com/ovh/go-ovh | |
1 | ||
2 | go 1.12 | |
3 | ||
4 | require ( | |
5 | // required by gopkg.in/ini.v1 unit tests... | |
6 | github.com/smartystreets/goconvey v1.6.4 // indirect | |
7 | gopkg.in/ini.v1 v1.57.0 | |
8 | ) |
0 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= | |
1 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= | |
2 | github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= | |
3 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= | |
4 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= | |
5 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= | |
6 | github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= | |
7 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= | |
8 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | |
9 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | |
10 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |
11 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |
12 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg= | |
13 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | |
14 | gopkg.in/ini.v1 v1.57.0 h1:9unxIsFcTt4I55uWluz+UmL95q4kdJ0buvQ1ZIqVQww= | |
15 | gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= |
26 | 26 | KimsufiCA = "https://ca.api.kimsufi.com/1.0" |
27 | 27 | SoyoustartEU = "https://eu.api.soyoustart.com/1.0" |
28 | 28 | SoyoustartCA = "https://ca.api.soyoustart.com/1.0" |
29 | RunaboveCA = "https://api.runabove.com/1.0" | |
30 | 29 | ) |
31 | 30 | |
32 | 31 | // Endpoints conveniently maps endpoints names to their URI for external configuration |
38 | 37 | "kimsufi-ca": KimsufiCA, |
39 | 38 | "soyoustart-eu": SoyoustartEU, |
40 | 39 | "soyoustart-ca": SoyoustartCA, |
41 | "runabove-ca": RunaboveCA, | |
42 | 40 | } |
43 | 41 | |
44 | 42 | // Errors |
418 | 416 | return nil |
419 | 417 | } |
420 | 418 | |
421 | return json.Unmarshal(body, &resType) | |
422 | } | |
419 | d := json.NewDecoder(bytes.NewReader(body)) | |
420 | d.UseNumber() | |
421 | return d.Decode(&resType) | |
422 | } |
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | func TestGetResponseUnmarshalNumber(t *testing.T) { | |
392 | var err error | |
393 | var output map[string]interface{} | |
394 | mockClient := Client{} | |
395 | ||
396 | // with map[string]interface{} as output | |
397 | err = mockClient.UnmarshalResponse(&http.Response{ | |
398 | StatusCode: 200, | |
399 | Body: ioutil.NopCloser(strings.NewReader(`{"orderId": 1234567890}`)), | |
400 | }, &output) | |
401 | if err != nil { | |
402 | t.Fatalf("Client.UnmarshalResponse should be able to decode the body") | |
403 | } | |
404 | if "1234567890" != fmt.Sprint(output["orderId"]) { | |
405 | t.Fatalf("Client.UnmarshalResponse should unmarshal long integer as json.Number instead of float64, stringified incorrectly") | |
406 | } | |
407 | ||
408 | var outputInt map[string]int64 | |
409 | ||
410 | // with map[string]int64 as output | |
411 | err = mockClient.UnmarshalResponse(&http.Response{ | |
412 | StatusCode: 200, | |
413 | Body: ioutil.NopCloser(strings.NewReader(`{"orderId": 1234567890}`)), | |
414 | }, &outputInt) | |
415 | if err != nil { | |
416 | t.Fatalf("Client.UnmarshalResponse should be able to decode the body") | |
417 | } | |
418 | if int64(1234567890) != outputInt["orderId"] { | |
419 | t.Fatalf("Client.UnmarshalResponse should unmarshal long integer as json.Number instead of float64, incorrectly casted as int64") | |
420 | } | |
421 | ||
422 | var outputFloat map[string]float64 | |
423 | ||
424 | // with map[string]int64 as output | |
425 | err = mockClient.UnmarshalResponse(&http.Response{ | |
426 | StatusCode: 200, | |
427 | Body: ioutil.NopCloser(strings.NewReader(`{"orderId": 1234567890}`)), | |
428 | }, &outputFloat) | |
429 | if err != nil { | |
430 | t.Fatalf("Client.UnmarshalResponse should be able to decode the body") | |
431 | } | |
432 | if float64(1234567890) != outputFloat["orderId"] { | |
433 | t.Fatalf("Client.UnmarshalResponse should unmarshal long integer as json.Number instead of float64, incorrectly casted as float64") | |
434 | } | |
435 | } | |
436 | ||
391 | 437 | func TestConstructors(t *testing.T) { |
392 | 438 | // Nominal: full constructor |
393 | 439 | client, err := NewClient("ovh-eu", MockApplicationKey, MockApplicationSecret, MockConsumerKey) |