Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
c.out
.env
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ module github.com/teamwork/vat/v3
go 1.21

require github.com/golang/mock v1.6.0

require github.com/joho/godotenv v1.5.1 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
17 changes: 15 additions & 2 deletions uk_vat_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ package vat

import (
"errors"
"os"
"testing"
"time"

"github.com/joho/godotenv"
)

// test numbers to use with the UK VAT service API in their sandbox environment:
Expand All @@ -25,11 +28,21 @@ var ukTests = []struct {
// TestUKVATService tests the UK VAT service. Just meant to be a quick way to check that this service is working.
// Makes external calls that sometimes might fail. Do not include them in CI/CD.
func TestUKVATService(t *testing.T) {
// Load environment variables from .env file
if err := godotenv.Load(); err != nil {
t.Fatalf("Error loading .env file: %v", err)
}

opts := ValidatorOpts{
UKClientID: "yourClientID", // insert your own client ID and secret here. Do not commit real values.
UKClientSecret: "yourClientSecret",
UKClientID: os.Getenv("CLIENT_ID"),
UKClientSecret: os.Getenv("SECRET"),
IsUKTest: true,
}

if opts.UKClientID == "" || opts.UKClientSecret == "" {
t.Fatal("CLIENT_ID and SECRET must be set in .env file")
}

token, err := GenerateUKAccessToken(opts)
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 2 additions & 0 deletions vies_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package vat
import (
"errors"
"testing"
"time"
)

var viesTests = []struct {
Expand All @@ -26,5 +27,6 @@ func TestViesService(t *testing.T) {
if !errors.Is(err, test.expectedError) {
t.Errorf("Expected <%v> for %v, got <%v>", test.expectedError, test.vatNumber, err)
}
time.Sleep(time.Second * 2) // delay to prevent rate limiting
}
}
Loading