Skip to content

Commit

Permalink
Removed the yd prefix from the package name
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterclaerhout committed Oct 1, 2019
1 parent ac0d2db commit 542ccdb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## go-ydfinance
## go-finance

[![Go Report Card](https://goreportcard.com/badge/github.com/pieterclaerhout/go-ydfinance)](https://goreportcard.com/report/github.com/pieterclaerhout/go-ydfinance)
[![Documentation](https://godoc.org/github.com/pieterclaerhout/go-ydfinance?status.svg)](http://godoc.org/github.com/pieterclaerhout/go-ydfinance)
[![GitHub issues](https://img.shields.io/github/issues/pieterclaerhout/go-ydfinance.svg)](https://github.com/pieterclaerhout/go-ydfinance/issues)
[![Go Report Card](https://goreportcard.com/badge/github.com/pieterclaerhout/go-finance)](https://goreportcard.com/report/github.com/pieterclaerhout/go-finance)
[![Documentation](https://godoc.org/github.com/pieterclaerhout/go-finance?status.svg)](http://godoc.org/github.com/pieterclaerhout/go-finance)
[![GitHub issues](https://img.shields.io/github/issues/pieterclaerhout/go-finance.svg)](https://github.com/pieterclaerhout/go-finance/issues)

This is a [Golang](https://golang.org) library which contains finance related functions.

Expand Down
2 changes: 1 addition & 1 deletion exchange_rates.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ydfinance
package finance

import (
"encoding/xml"
Expand Down
2 changes: 1 addition & 1 deletion exchange_rates_model.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ydfinance
package finance

// exchangeRate defines the exchange rate
type exchangeRate struct {
Expand Down
26 changes: 13 additions & 13 deletions exchange_rates_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ydfinance_test
package finance_test

import (
"net/http"
Expand All @@ -8,12 +8,12 @@ import (

"github.com/stretchr/testify/assert"

"github.com/pieterclaerhout/go-ydfinance"
"github.com/pieterclaerhout/go-finance"
)

func Test_ExchangeRates_Valid(t *testing.T) {

rates, err := ydfinance.ExchangeRates()
rates, err := finance.ExchangeRates()

assert.NoErrorf(t, err, "err should be nil, is: %v", err)
assert.NotNilf(t, rates, "rates should not be nil")
Expand All @@ -23,10 +23,10 @@ func Test_ExchangeRates_Valid(t *testing.T) {

func Test_ExchangeRates_InvalidURL(t *testing.T) {

ydfinance.RatesURL = "ht&@-tp://:aa"
finance.RatesURL = "ht&@-tp://:aa"
defer resetRatesURL()

rates, err := ydfinance.ExchangeRates()
rates, err := finance.ExchangeRates()

assert.Error(t, err)
assert.Empty(t, rates)
Expand All @@ -35,7 +35,7 @@ func Test_ExchangeRates_InvalidURL(t *testing.T) {

func Test_ExchangeRates_Timeout(t *testing.T) {

ydfinance.DefaultTimeout = 250 * time.Millisecond
finance.DefaultTimeout = 250 * time.Millisecond

s := httptest.NewServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -46,10 +46,10 @@ func Test_ExchangeRates_Timeout(t *testing.T) {
)
defer s.Close()

ydfinance.RatesURL = s.URL
finance.RatesURL = s.URL
defer resetRatesURL()

rates, err := ydfinance.ExchangeRates()
rates, err := finance.ExchangeRates()

assert.Error(t, err)
assert.Empty(t, rates)
Expand All @@ -65,10 +65,10 @@ func Test_ExchangeRates_ReadBodyError(t *testing.T) {
)
defer s.Close()

ydfinance.RatesURL = s.URL
finance.RatesURL = s.URL
defer resetRatesURL()

rates, err := ydfinance.ExchangeRates()
rates, err := finance.ExchangeRates()

assert.Error(t, err)
assert.Empty(t, rates)
Expand All @@ -85,16 +85,16 @@ func Test_ExchangeRates_InvalidXML(t *testing.T) {
)
defer s.Close()

ydfinance.RatesURL = s.URL
finance.RatesURL = s.URL
defer resetRatesURL()

rates, err := ydfinance.ExchangeRates()
rates, err := finance.ExchangeRates()

assert.Error(t, err)
assert.Empty(t, rates)

}

func resetRatesURL() {
ydfinance.RatesURL = ydfinance.DefaultRatesURL
finance.RatesURL = finance.DefaultRatesURL
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/pieterclaerhout/go-ydfinance
module github.com/pieterclaerhout/go-finance

go 1.13

Expand Down
2 changes: 1 addition & 1 deletion vies.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ydfinance
package finance

import (
"bytes"
Expand Down
52 changes: 26 additions & 26 deletions vies_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ydfinance_test
package finance_test

import (
"net/http"
Expand All @@ -8,7 +8,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/pieterclaerhout/go-ydfinance"
"github.com/pieterclaerhout/go-finance"
)

func Test_Check(t *testing.T) {
Expand All @@ -25,7 +25,7 @@ func Test_Check(t *testing.T) {
}

var tests = []test{
{"empty", "", "", "", "", "", false, ydfinance.ErrVATNumberTooShort},
{"empty", "", "", "", "", "", false, finance.ErrVATNumberTooShort},
{"valid-spaces", "BE 0836 157 420", "BE", "0836157420", "SPRL APPLE RETAIL BELGIUM", "Avenue du Port 86C/204\n1000 Bruxelles", true, nil},
{"valid-nospaces", "BE0836157420", "BE", "0836157420", "SPRL APPLE RETAIL BELGIUM", "Avenue du Port 86C/204\n1000 Bruxelles", true, nil},
{"valid-dots", "BE 0836.157.420", "BE", "0836157420", "SPRL APPLE RETAIL BELGIUM", "Avenue du Port 86C/204\n1000 Bruxelles", true, nil},
Expand All @@ -36,7 +36,7 @@ func Test_Check(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {

result, err := ydfinance.CheckVAT(tc.vatNumber)
result, err := finance.CheckVAT(tc.vatNumber)

if tc.expectedError != nil {

Expand All @@ -63,12 +63,12 @@ func Test_Check(t *testing.T) {

func Test_Check_InvalidURL(t *testing.T) {

ydfinance.VATServiceURL = "ht&@-tp://:aa"
finance.VATServiceURL = "ht&@-tp://:aa"
defer func() {
ydfinance.VATServiceURL = ydfinance.DefaultVATServiceURL
finance.VATServiceURL = finance.DefaultVATServiceURL
}()

result, err := ydfinance.CheckVAT("BE0836157420")
result, err := finance.CheckVAT("BE0836157420")

assert.Nil(t, result, "result")
assert.Error(t, err, "error")
Expand All @@ -86,14 +86,14 @@ func Test_Check_Timeout(t *testing.T) {
)
defer s.Close()

ydfinance.VATTimeout = 250 * time.Millisecond
ydfinance.VATServiceURL = s.URL
finance.VATTimeout = 250 * time.Millisecond
finance.VATServiceURL = s.URL
defer func() {
ydfinance.VATTimeout = ydfinance.DefaultVATTimeout
ydfinance.VATServiceURL = ydfinance.DefaultVATServiceURL
finance.VATTimeout = finance.DefaultVATTimeout
finance.VATServiceURL = finance.DefaultVATServiceURL
}()

result, err := ydfinance.CheckVAT("BE0836157420")
result, err := finance.CheckVAT("BE0836157420")

assert.Nil(t, result, "result")
assert.Error(t, err, "error")
Expand All @@ -109,12 +109,12 @@ func Test_Check_ReadBodyError(t *testing.T) {
)
defer s.Close()

ydfinance.VATServiceURL = s.URL
finance.VATServiceURL = s.URL
defer func() {
ydfinance.VATServiceURL = ydfinance.DefaultVATServiceURL
finance.VATServiceURL = finance.DefaultVATServiceURL
}()

result, err := ydfinance.CheckVAT("BE0836157420")
result, err := finance.CheckVAT("BE0836157420")

assert.Nil(t, result, "result")
assert.Error(t, err, "error")
Expand All @@ -130,16 +130,16 @@ func Test_Check_InvalidInput(t *testing.T) {
)
defer s.Close()

ydfinance.VATServiceURL = s.URL
finance.VATServiceURL = s.URL
defer func() {
ydfinance.VATServiceURL = ydfinance.DefaultVATServiceURL
finance.VATServiceURL = finance.DefaultVATServiceURL
}()

result, err := ydfinance.CheckVAT("BE0836157420")
result, err := finance.CheckVAT("BE0836157420")

assert.Nil(t, result, "result")
assert.Error(t, err, "error")
assert.Equal(t, ydfinance.ErrVATnumberNotValid, err)
assert.Equal(t, finance.ErrVATnumberNotValid, err)

}

Expand All @@ -152,12 +152,12 @@ func Test_Check_InvalidXML(t *testing.T) {
)
defer s.Close()

ydfinance.VATServiceURL = s.URL
finance.VATServiceURL = s.URL
defer func() {
ydfinance.VATServiceURL = ydfinance.DefaultVATServiceURL
finance.VATServiceURL = finance.DefaultVATServiceURL
}()

result, err := ydfinance.CheckVAT("BE0836157420")
result, err := finance.CheckVAT("BE0836157420")

assert.Nil(t, result, "result")
assert.Error(t, err, "error")
Expand All @@ -173,15 +173,15 @@ func Test_Check_SoapFault(t *testing.T) {
)
defer s.Close()

ydfinance.VATServiceURL = s.URL
finance.VATServiceURL = s.URL
defer func() {
ydfinance.VATServiceURL = ydfinance.DefaultVATServiceURL
finance.VATServiceURL = finance.DefaultVATServiceURL
}()

result, err := ydfinance.CheckVAT("BE0836157420")
result, err := finance.CheckVAT("BE0836157420")

assert.Nil(t, result, "result")
assert.Error(t, err, "error")
assert.Equal(t, ydfinance.ErrVATserviceError+"error", err.Error(), "error-message")
assert.Equal(t, finance.ErrVATserviceError+"error", err.Error(), "error-message")

}

0 comments on commit 542ccdb

Please sign in to comment.