Skip to content

Commit e6b6144

Browse files
committed
Refactor CodeBase To Cater For Airtime Module
Move airtime related operations to a specified module Update Circle CI test command to cater for tests in subfolders Fix imports broken due to refactoring
1 parent adc355a commit e6b6144

26 files changed

+117
-30
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- "/go/pkg/mod"
1919
- run:
2020
name: Run tests
21-
command: go test -race -coverprofile=coverage.txt -covermode=atomic
21+
command: go test ./... -race -coverprofile=coverage.txt -covermode=atomic
2222
- run:
2323
name: Upload Coverage
2424
when: on_success

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# Reloadly SDK for Golang
44

55
[![CircleCI][circle-ci-badge]][circle-ci-url] [![MIT][mit-badge]][mit-url] [![codecov][codecov-badge]][codecov-url]
6-
<!--[![Maven][maven-badge]][maven-url]-->
7-
86
The **Reloadly SDK for Golang** enables Go developers to easily work with [Reloadly Services][reloadly-main-site] and build scalable solutions. You can get started in minutes if you have Go 1.15+ installed on your machine.
97

108
* [SDK Homepage][sdk-website] (Coming soon)
@@ -118,9 +116,9 @@ This project is licensed under the MIT license. See the [LICENSE](LICENSE) file
118116

119117
[circle-ci-url]: https://app.circleci.com/pipelines/github/Reloadly/reloadly-sdk-golang
120118

121-
[codecov-badge]: https://codecov.io/gh/reloadly/reloadly-sdk-java/branch/main/graph/badge.svg?token=8U89VKQ2BF
119+
[codecov-badge]: https://codecov.io/gh/Reloadly/reloadly-sdk-golang/branch/main/graph/badge.svg?token=SUV66Q3J2Y
122120

123-
[codecov-url]: https://app.codecov.io/gh/reloadly/reloadly-sdk-java
121+
[codecov-url]: https://codecov.io/gh/Reloadly/reloadly-sdk-golang
124122

125123
[youtube-series]: https://www.youtube.com/watch?v=TbXC4Ic8x30&t=141s&ab_channel=Reloadly
126124

accounts.go renamed to airtime/accounts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package reloadly
1+
package airtime
22

33
import (
44
"encoding/json"

accounts_test.go renamed to airtime/accounts_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package reloadly_test
1+
package airtime_test
22

33
import (
44
"encoding/json"
5-
"github.com/reloadly/reloadly-sdk-golang"
5+
reloadly "github.com/reloadly/reloadly-sdk-golang/airtime"
66
"net/http"
77
"testing"
88
)

countries.go renamed to airtime/countries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package reloadly
1+
package airtime
22

33
import (
44
"encoding/json"

airtime/countries_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package airtime_test
2+
3+
import (
4+
"net/http"
5+
"testing"
6+
)
7+
8+
func TestClient_GetCountries(t *testing.T) {
9+
teardown := setup()
10+
11+
defer teardown()
12+
13+
mux.HandleFunc("/countries", func(rw http.ResponseWriter, req *http.Request) {
14+
rw.WriteHeader(http.StatusInternalServerError)
15+
})
16+
17+
body, err := client.GetCountries()
18+
19+
if err == nil {
20+
t.Errorf("Expected error to be %q but got nil", err)
21+
}
22+
23+
if body != nil {
24+
t.Errorf("Expected body to be nil but got %q", body)
25+
}
26+
}

discounts.go renamed to airtime/discounts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package reloadly
1+
package airtime
22

33
import (
44
"encoding/json"

airtime/discounts_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package airtime_test
2+
3+
import (
4+
"encoding/json"
5+
reloadly "github.com/reloadly/reloadly-sdk-golang/airtime"
6+
"net/http"
7+
"testing"
8+
)
9+
10+
func TestClient_GetDiscounts(t *testing.T) {
11+
teardown := setup()
12+
13+
defer teardown()
14+
15+
mux.HandleFunc("/operators/commissions", func(rw http.ResponseWriter, req *http.Request) {
16+
rw.WriteHeader(http.StatusOK)
17+
data := reloadly.Discounts{
18+
TotalElements: 20,
19+
TotalPages: 5,
20+
}
21+
json.NewEncoder(rw).Encode(data)
22+
23+
})
24+
25+
body, err := client.GetDiscounts()
26+
if err != nil {
27+
t.Errorf("Expected error to be nil but got %q", err)
28+
}
29+
30+
if body.TotalPages != 5 {
31+
t.Errorf("Expected TotalPages to be 5 but got %v", body.TotalPages)
32+
}
33+
34+
if body.TotalElements != 20 {
35+
t.Errorf("Expected TotalElements to be 20 but got %v", body.TotalElements)
36+
}
37+
}

operators.go renamed to airtime/operators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package reloadly
1+
package airtime
22

33
import (
44
"bytes"

operators_test.go renamed to airtime/operators_test.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package reloadly_test
1+
package airtime_test
22

33
import (
44
"encoding/json"
5-
"github.com/reloadly/reloadly-sdk-golang"
5+
reloadly "github.com/reloadly/reloadly-sdk-golang/airtime"
66
"net/http"
77
"testing"
88
)
@@ -55,4 +55,30 @@ func TestClient_GetFXRate(t *testing.T) {
5555
if body.FxRate != 65 {
5656
t.Errorf("Expected OperatorID to be 65 but got %v", body.FxRate)
5757
}
58+
}
59+
60+
func TestClient_GetOperatorsByISO(t *testing.T) {
61+
teardown := setup()
62+
63+
defer teardown()
64+
65+
mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
66+
rw.WriteHeader(http.StatusOK)
67+
data := reloadly.Operators{
68+
TotalPages: 5,
69+
Size: 20,
70+
}
71+
72+
json.NewEncoder(rw).Encode(data)
73+
74+
})
75+
76+
body, err := client.GetOperatorsByISO("011")
77+
if err != nil {
78+
t.Errorf("Expected error to be nil but got %q", err)
79+
}
80+
81+
if body.Size != 20 {
82+
t.Errorf("Expected Size to be 20 but got %v", body.Size)
83+
}
5884
}

0 commit comments

Comments
 (0)