summaryrefslogtreecommitdiffstats
path: root/lib/geoip/geoip_test.go
blob: f2098c6c090db4f4812ecaa72dae9884f03d4693 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (C) 2024 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

package geoip

import (
	"net"
	"os"
	"strconv"
	"testing"
)

func TestDownloadAndOpen(t *testing.T) {
	acctID, _ := strconv.Atoi(os.Getenv("GEOIP_ACCOUNT_ID"))
	if acctID == 0 {
		t.Skip("No account ID set")
	}
	license := os.Getenv("GEOIP_LICENSE_KEY")
	if license == "" {
		t.Skip("No license key set")
	}

	p := NewGeoLite2CityProvider(acctID, license, t.TempDir())
	_, err := p.City(net.ParseIP("8.8.8.8"))
	if err != nil {
		t.Fatal(err)
	}
}