Skip to content

Commit a105efc

Browse files
Tests (#18)
* circle ci tests * build and test badges
1 parent c8c7bb3 commit a105efc

File tree

5 files changed

+82
-35
lines changed

5 files changed

+82
-35
lines changed

.circleci/config.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2.0
2+
3+
orbs:
4+
codecov: codecov/[email protected]
5+
6+
jobs:
7+
build:
8+
docker:
9+
- image: circleci/golang:1.12
10+
steps:
11+
- checkout
12+
- run:
13+
name: "Create directories"
14+
command: |
15+
mkdir -p /tmp/artifacts
16+
- run:
17+
name: "Run tests and collect coverage reports"
18+
command: |
19+
make test
20+
mv coverage.html /tmp/artifacts
21+
mv c.out /tmp/artifacts
22+
- store_artifacts:
23+
path: /tmp/artifacts
24+
- run:
25+
name: Upload Coverage Results
26+
command: "bash <(curl -s https://codecov.io/bash) \
27+
-f /tmp/artifacts/* \
28+
-n ${CIRCLE_BUILD_NUM} \
29+
-t ${CODECOV_TOKEN} \
30+
-y .codecov.yml"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
22
.env
3-
vendor
3+
vendor
4+
c.out
5+
coverage.html

Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
tests:
2-
go test ./... -v
1+
deps:
2+
go mod vendor
3+
.PHONY: deps
4+
5+
lint:
6+
golint $(PKGS)
7+
.PHONY: lint
8+
9+
test-unit:
10+
go test ./... --race --cover -count=1 -timeout 1s -coverprofile=c.out -v
11+
.PHONY: test-unit
12+
13+
coverage-html:
14+
go tool cover -html=c.out -o coverage.html
15+
16+
test: deps test-unit coverage-html
17+
.PHONY: test

README.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Amadeus WBS SDK
22

3+
[![CircleCI](https://circleci.com/gh/tmconsulting/amadeus-golang-sdk/tree/temass-refactoringsts.svg?style=shield)](https://circleci.com/gh/tmconsulting/amadeus-golang-sdk/tree/tests) [![codecov](https://codecov.io/gh/tmconsulting/amadeus-golang-sdk/branch/mass-refactoring/graph/badge.svg)](https://codecov.io/gh/tmconsulting/amadeus-golang-sdk)
4+
35
This package contains structures, forms, functions and SOAP handler for Amadeus WS.
46

57
## Methods implementation progress
@@ -26,6 +28,7 @@ This package contains structures, forms, functions and SOAP handler for Amadeus
2628
- [ ] Queue_RemoveItem (03.1)
2729
- [x] Security_Authenticate (06.1)
2830
- [x] Security_SignOut (04.1)
31+
- [ ] Service_BookPriceService
2932
- [x] Ticket_CreateTSTFromPricing (04.1)
3033
- [ ] Ticket_CreditCardCheck (06.1)
3134
- [x] Ticket_DeleteTST (04.1)
@@ -36,47 +39,51 @@ This package contains structures, forms, functions and SOAP handler for Amadeus
3639

3740
It is go gettable and go.mod powered
3841

39-
$ go get github.com/tmconsulting/amadeus-golang-sdk@latest
42+
$ go get github.com/tmconsulting/amadeus-golang-sdk@mass-refactoring
4043

4144
## Usage
4245

43-
Prepare log writer realisation if you need to see outgoing and incoming xmls (null logging used if nil is passed),
44-
methods map that you want (and allowed by Amadeus) to run (use `GetLatestMethodsMap()` to use latest methods versions
45-
that are implemented) and credentials to connect: url, originator, password (not in base64!). Initiate SDK and service:
46+
Prepare log writer realisation if you need to see outgoing and incoming xmls (null logging used if nil is passed).
47+
Check methods version that will be used in SDK (use `GetLatestMethodsMap()` to use latest methods versions that are
48+
implemented). Ыуе credentials to connect: url, originator, password (not in base64!). Initiate SDK and service and use
49+
service methods:
4650

4751
```go
4852
package main
4953

5054
import (
51-
"log"
52-
53-
"github.com/tmconsulting/amadeus-golang-sdk/logger/stdoutLogger"
54-
"github.com/tmconsulting/amadeus-golang-sdk/sdk"
55-
"github.com/tmconsulting/amadeus-golang-sdk/service"
55+
"log"
56+
57+
"github.com/tmconsulting/amadeus-golang-sdk/client"
58+
"github.com/tmconsulting/amadeus-golang-sdk/service"
59+
"github.com/tmconsulting/amadeus-golang-sdk/structs/commandCryptic"
5660
)
5761

5862
func main() {
59-
url := "https://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXX"
60-
originator := "WSBENXXX"
61-
passwordRaw := "dGhlIHBhc3N3b3Jk"
62-
officeID := "BRUXX1111"
63-
client := sdk.CreateAmadeusClient(url, originator, passwordRaw, officeID, stdoutLogger.Init())
64-
65-
amadeusSDK := service.NewSKD(client, service.GetLatestMethodsMap())
66-
67-
response, err := amadeusSDK.CommandCryptic("AN20MAYMOWLED/ALH")
68-
if err != nil {
69-
log.Fatalf("error: %v", err)
70-
}
71-
72-
log.Printf("response: %v\n", response)
63+
url := "https://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXX"
64+
originator := "WSBENXXX"
65+
passwordRaw := "dGhlIHBhc3N3b3Jk"
66+
officeID := "BRUXX1111"
67+
68+
cl := client.New(client.SetURL(url), client.SetUser(originator), client.SetPassword(passwordRaw), client.SetAgent(officeID))
69+
s := service.New(cl)
70+
71+
resp, err := s.CommandCryptic("AN20DECMOWLED/ALH")
72+
if err != nil {
73+
panic(err)
74+
}
75+
76+
log.Printf("responses: %v\n", resp)
7377
}
7478
```
7579

7680
## Testing
7781

78-
Create test `.env` file from [test.env-example](test.env-example), or run with ENV variables `make test`
79-
(or `go test ./... -v`)
82+
Run tests (`make test` or `go test ./... -v`) with ENV variabless:
83+
* URL
84+
* ORIGINATOR
85+
* PASSWORD_RAW
86+
* OFFICE_ID
8087

8188
## Contribution
8289

service/service_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"os"
66
"testing"
77

8-
"github.com/joho/godotenv"
9-
108
"github.com/stretchr/testify/assert"
119

1210
"github.com/tmconsulting/amadeus-golang-sdk/client"
@@ -24,11 +22,6 @@ var (
2422
)
2523

2624
func tearUp() {
27-
err := godotenv.Load("../.env")
28-
if err != nil {
29-
log.Fatal("Error loading .env file")
30-
}
31-
3225
url = os.Getenv("URL")
3326
originator = os.Getenv("ORIGINATOR")
3427
passwordRaw = os.Getenv("PASSWORD_RAW")

0 commit comments

Comments
 (0)