mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
698 B
40 lines
698 B
2 years ago
|
// Copyright 2023 ROC. All rights reserved.
|
||
2 years ago
|
// Use of this source code is governed by a MIT style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
2 years ago
|
package utils_test
|
||
3 years ago
|
|
||
2 years ago
|
import (
|
||
|
. "github.com/onsi/ginkgo/v2"
|
||
|
. "github.com/onsi/gomega"
|
||
3 years ago
|
|
||
2 years ago
|
"github.com/rocboss/paopao-ce/pkg/utils"
|
||
2 years ago
|
)
|
||
|
|
||
|
var _ = Describe("Ip", Ordered, func() {
|
||
|
type iplocs []struct {
|
||
|
ip string
|
||
|
location string
|
||
3 years ago
|
}
|
||
2 years ago
|
var samples iplocs
|
||
|
|
||
|
BeforeAll(func() {
|
||
|
samples = iplocs{
|
||
|
{
|
||
|
ip: "",
|
||
|
location: "",
|
||
3 years ago
|
},
|
||
2 years ago
|
{
|
||
|
ip: "103.197.70.244",
|
||
|
location: "香港",
|
||
3 years ago
|
},
|
||
2 years ago
|
}
|
||
|
})
|
||
|
|
||
|
It("get ip location", func() {
|
||
|
for _, t := range samples {
|
||
2 years ago
|
Expect(utils.GetIPLoc(t.ip)).To(Equal(t.location))
|
||
2 years ago
|
}
|
||
|
})
|
||
|
})
|