Skip to content

Commit

Permalink
Lint-fix for tests of pipeline-stage geoip
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Dec 9, 2023
1 parent fd13fe0 commit 516dbd1
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions component/loki/process/stages/geoip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
"github.com/stretchr/testify/require"
)

var (
geoipTestIP string = "192.0.2.1"
geoipTestSource string = "dummy"
)

func Test_ValidateConfigs(t *testing.T) {
source := "ip"
tests := []struct {
Expand Down Expand Up @@ -108,18 +113,16 @@ func Test_MaxmindAsn(t *testing.T) {
return
}
defer mmdb.Close()
ip := "192.0.2.1"

var record geoip2.ASN
err = mmdb.Lookup(net.ParseIP(ip), &record)
err = mmdb.Lookup(net.ParseIP(geoipTestIP), &record)
if err != nil {
t.Error(err)
}

source := "dummy"
config := GeoIPConfig{
DB: "test",
Source: &source,
Source: &geoipTestSource,
DBType: "asn",
}
valuesExpressions, err := validateGeoIPConfig(config)
Expand Down Expand Up @@ -154,18 +157,16 @@ func Test_MaxmindCity(t *testing.T) {
return
}
defer mmdb.Close()
ip := "192.0.2.1"

var record geoip2.City
err = mmdb.Lookup(net.ParseIP(ip), &record)
err = mmdb.Lookup(net.ParseIP(geoipTestIP), &record)
if err != nil {
t.Error(err)
}

source := "dummy"
config := GeoIPConfig{
DB: "test",
Source: &source,
Source: &geoipTestSource,
DBType: "city",
}
valuesExpressions, err := validateGeoIPConfig(config)
Expand Down Expand Up @@ -210,18 +211,16 @@ func Test_MaxmindCountry(t *testing.T) {
return
}
defer mmdb.Close()
ip := "192.0.2.1"

var record geoip2.Country
err = mmdb.Lookup(net.ParseIP(ip), &record)
err = mmdb.Lookup(net.ParseIP(geoipTestIP), &record)
if err != nil {
t.Error(err)
}

source := "dummy"
config := GeoIPConfig{
DB: "test",
Source: &source,
Source: &geoipTestSource,
DBType: "country",
}
valuesExpressions, err := validateGeoIPConfig(config)
Expand Down

0 comments on commit 516dbd1

Please sign in to comment.