-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into addon-verifactu
- Loading branch information
Showing
18 changed files
with
314 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/invopop/gobl/org" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAddressNormalize(t *testing.T) { | ||
t.Run("nil address", func(t *testing.T) { | ||
var a *org.Address | ||
assert.NotPanics(t, func() { | ||
a.Normalize(nil) | ||
}) | ||
}) | ||
|
||
t.Run("normalize fields", func(t *testing.T) { | ||
a := &org.Address{ | ||
PostOfficeBox: " 20 ", | ||
Number: " 12 ", | ||
Floor: " 3 ", | ||
Block: " A ", | ||
Door: " 1 ", | ||
Street: " Main St. ", | ||
StreetExtra: " Apt. 3 ", | ||
Locality: " Town ", | ||
Region: " City ", | ||
State: " MAD ", | ||
Code: " HG12 2AB ", | ||
} | ||
a.Normalize(nil) | ||
|
||
assert.Equal(t, "20", a.PostOfficeBox) | ||
assert.Equal(t, "12", a.Number) | ||
assert.Equal(t, "3", a.Floor) | ||
assert.Equal(t, "A", a.Block) | ||
assert.Equal(t, "1", a.Door) | ||
assert.Equal(t, "Main St.", a.Street) | ||
assert.Equal(t, "Apt. 3", a.StreetExtra) | ||
assert.Equal(t, "Town", a.Locality) | ||
assert.Equal(t, "City", a.Region) | ||
assert.Equal(t, "MAD", a.State.String()) | ||
assert.Equal(t, "HG12 2AB", a.Code.String()) | ||
}) | ||
} | ||
|
||
func TestAddressValidation(t *testing.T) { | ||
t.Run("valid address", func(t *testing.T) { | ||
a := &org.Address{ | ||
Number: "12", | ||
Street: "Main St.", | ||
Locality: "Town", | ||
Region: "City", | ||
State: "MAD", | ||
Code: "HG12 2AB", | ||
Country: "GB", | ||
} | ||
assert.NoError(t, a.Validate()) | ||
}) | ||
|
||
t.Run("invalid UUID", func(t *testing.T) { | ||
a := &org.Address{ | ||
Number: "12", | ||
Street: "Main St.", | ||
Locality: "Town", | ||
Region: "City", | ||
State: "MAD", | ||
Code: "HG12 2AB", | ||
Country: "GB", | ||
} | ||
a.UUID = "invalid" | ||
assert.ErrorContains(t, a.Validate(), "uuid: invalid UUID length: 7") | ||
}) | ||
} |
Oops, something went wrong.