Skip to content

Commit

Permalink
test: download database before running tests
Browse files Browse the repository at this point in the history
the goals is to avoid having to commit the database blob
  • Loading branch information
noandrea committed Jun 24, 2024
1 parent dd3bbdd commit 7afcae4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 46 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test-coverage:
go tool cover -html=coverage.out

test-ci:
go run main.go update current
go test -coverprofile=coverage.txt -covermode=atomic -race -mod=readonly $(GOPACKAGES)

bench: bench-all
Expand Down Expand Up @@ -68,5 +69,5 @@ update-tzdata:
@echo "--> Updating timzaone data"
@echo build binary
goreleaser build --single-target --config .github/.goreleaser.yaml --snapshot --clean -o geo2tz
./geo2tz update
./geo2tz update latest
@echo done
17 changes: 14 additions & 3 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ const (
var updateCmd = &cobra.Command{
Use: "update VERSION",
Short: "Download the timezone data from the latest release or a specific version",
Example: `To build from the latest version:
Example: `To update using the tzdata/version.json file:
geo2tz update current
To update to the latest version:
geo2tz update latest
To build from a specific version:
To update to a specific version:
geo2tz update 2023d
`,
Args: cobra.ExactArgs(1),
Expand All @@ -65,10 +68,18 @@ func update(versionName, targetFile string) (err error) {
return
}
}
// shall we read from the version file?
if versionName == "current" {
err = helpers.LoadJSON(web.Settings.Tz.VersionFile, &release)
if err != nil {
return
}
println("Current version is", release.URL)
}
if err := fetchAndCacheFile(targetFile, release.GeoDataURL); err != nil {
return err
}
helpers.SaveJSON(release, web.Settings.Tz.VersionFile)
err = helpers.SaveJSON(release, web.Settings.Tz.VersionFile)
return
}

Expand Down
42 changes: 0 additions & 42 deletions coverage.out

This file was deleted.

0 comments on commit 7afcae4

Please sign in to comment.