Skip to content

Commit

Permalink
Tests (#18)
Browse files Browse the repository at this point in the history
* circle ci tests

* build and test badges
  • Loading branch information
smgladkovskiy authored Jul 16, 2019
1 parent c8c7bb3 commit a105efc
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 35 deletions.
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2.0

orbs:
codecov: codecov/[email protected]

jobs:
build:
docker:
- image: circleci/golang:1.12
steps:
- checkout
- run:
name: "Create directories"
command: |
mkdir -p /tmp/artifacts
- run:
name: "Run tests and collect coverage reports"
command: |
make test
mv coverage.html /tmp/artifacts
mv c.out /tmp/artifacts
- store_artifacts:
path: /tmp/artifacts
- run:
name: Upload Coverage Results
command: "bash <(curl -s https://codecov.io/bash) \
-f /tmp/artifacts/* \
-n ${CIRCLE_BUILD_NUM} \
-t ${CODECOV_TOKEN} \
-y .codecov.yml"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
.env
vendor
vendor
c.out
coverage.html
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
tests:
go test ./... -v
deps:
go mod vendor
.PHONY: deps

lint:
golint $(PKGS)
.PHONY: lint

test-unit:
go test ./... --race --cover -count=1 -timeout 1s -coverprofile=c.out -v
.PHONY: test-unit

coverage-html:
go tool cover -html=c.out -o coverage.html

test: deps test-unit coverage-html
.PHONY: test
57 changes: 32 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Amadeus WBS SDK

[![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)

This package contains structures, forms, functions and SOAP handler for Amadeus WS.

## Methods implementation progress
Expand All @@ -26,6 +28,7 @@ This package contains structures, forms, functions and SOAP handler for Amadeus
- [ ] Queue_RemoveItem (03.1)
- [x] Security_Authenticate (06.1)
- [x] Security_SignOut (04.1)
- [ ] Service_BookPriceService
- [x] Ticket_CreateTSTFromPricing (04.1)
- [ ] Ticket_CreditCardCheck (06.1)
- [x] Ticket_DeleteTST (04.1)
Expand All @@ -36,47 +39,51 @@ This package contains structures, forms, functions and SOAP handler for Amadeus

It is go gettable and go.mod powered

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

## Usage

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

```go
package main

import (
"log"
"github.com/tmconsulting/amadeus-golang-sdk/logger/stdoutLogger"
"github.com/tmconsulting/amadeus-golang-sdk/sdk"
"github.com/tmconsulting/amadeus-golang-sdk/service"
"log"
"github.com/tmconsulting/amadeus-golang-sdk/client"
"github.com/tmconsulting/amadeus-golang-sdk/service"
"github.com/tmconsulting/amadeus-golang-sdk/structs/commandCryptic"
)

func main() {
url := "https://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXX"
originator := "WSBENXXX"
passwordRaw := "dGhlIHBhc3N3b3Jk"
officeID := "BRUXX1111"
client := sdk.CreateAmadeusClient(url, originator, passwordRaw, officeID, stdoutLogger.Init())

amadeusSDK := service.NewSKD(client, service.GetLatestMethodsMap())

response, err := amadeusSDK.CommandCryptic("AN20MAYMOWLED/ALH")
if err != nil {
log.Fatalf("error: %v", err)
}

log.Printf("response: %v\n", response)
url := "https://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXX"
originator := "WSBENXXX"
passwordRaw := "dGhlIHBhc3N3b3Jk"
officeID := "BRUXX1111"
cl := client.New(client.SetURL(url), client.SetUser(originator), client.SetPassword(passwordRaw), client.SetAgent(officeID))
s := service.New(cl)
resp, err := s.CommandCryptic("AN20DECMOWLED/ALH")
if err != nil {
panic(err)
}
log.Printf("responses: %v\n", resp)
}
```

## Testing

Create test `.env` file from [test.env-example](test.env-example), or run with ENV variables `make test`
(or `go test ./... -v`)
Run tests (`make test` or `go test ./... -v`) with ENV variabless:
* URL
* ORIGINATOR
* PASSWORD_RAW
* OFFICE_ID

## Contribution

Expand Down
7 changes: 0 additions & 7 deletions service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"os"
"testing"

"github.com/joho/godotenv"

"github.com/stretchr/testify/assert"

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

func tearUp() {
err := godotenv.Load("../.env")
if err != nil {
log.Fatal("Error loading .env file")
}

url = os.Getenv("URL")
originator = os.Getenv("ORIGINATOR")
passwordRaw = os.Getenv("PASSWORD_RAW")
Expand Down

0 comments on commit a105efc

Please sign in to comment.