Add tests for data
parent
74dd1ebfd1
commit
9cffe08a20
|
@ -38,7 +38,7 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
|
||||
- name: Vet code
|
||||
run: go vet
|
||||
run: go vet ./...
|
||||
|
||||
format:
|
||||
name: Format
|
||||
|
@ -59,7 +59,7 @@ jobs:
|
|||
git config --local user.name "GitHub Action"
|
||||
|
||||
- name: Format code
|
||||
run: gofmt -l -w -s .
|
||||
run: gofmt -l -w -s ./...
|
||||
|
||||
- name: Commit and push changes
|
||||
id: commit-dockerfiles
|
||||
|
|
2
Makefile
2
Makefile
|
@ -21,7 +21,7 @@ datetime: *.go data/*.go
|
|||
|
||||
.PHONY: test
|
||||
test: data
|
||||
$(GO) test -cover -bench=. -v
|
||||
$(GO) test -cover -bench=. -v ./...
|
||||
|
||||
|
||||
DATASETS = \
|
||||
|
|
|
@ -205,6 +205,7 @@ d-zoneinfo {
|
|||
d-zonename {
|
||||
display: inline;
|
||||
|
||||
font-size: 0.75em;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ func extendName(names ...string) string {
|
|||
// FullName returns a fully qualified human readable name
|
||||
func (c City) FullName() string {
|
||||
if len(c.Admin1.Name) > 0 {
|
||||
return extendName(c.Name, c.Admin1.Name, c.Country.Name)
|
||||
return extendName(c.Name, c.Admin1.Name, c.Country.Ref)
|
||||
}
|
||||
return extendName(c.Name, c.Country.Name)
|
||||
return extendName(c.Name, c.Country.Ref)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package data
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCityFullName(t *testing.T) {
|
||||
c := City{
|
||||
Name: "'cit-y N'ame-",
|
||||
Admin1: Admin1{
|
||||
Name: "a-dmin1, Name'",
|
||||
},
|
||||
Country: Country{
|
||||
Name: "Country Name",
|
||||
Ref: "CN",
|
||||
},
|
||||
}
|
||||
|
||||
got, want := c.FullName(), "'cit-y N'ame-, a-dmin1, Name', CN"
|
||||
if got != want {
|
||||
t.Errorf("got %v, want %v", got, want)
|
||||
}
|
||||
|
||||
c = City{
|
||||
Name: "City Name",
|
||||
Admin1: Admin1{},
|
||||
Country: Country{
|
||||
Name: "Name Country",
|
||||
Ref: "CN",
|
||||
},
|
||||
}
|
||||
|
||||
got, want = c.FullName(), "City Name, CN"
|
||||
if got != want {
|
||||
t.Errorf("got %v, want %v", got, want)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue