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.
41 lines
672 B
41 lines
672 B
// Copyright 2022 ROC. All rights reserved.
|
|
// Use of this source code is governed by a MIT style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package util
|
|
|
|
import "testing"
|
|
|
|
func TestGetIPLoc(t *testing.T) {
|
|
type args struct {
|
|
ip string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want string
|
|
}{
|
|
{
|
|
name: "test1",
|
|
args: args{
|
|
ip: "",
|
|
},
|
|
want: "",
|
|
},
|
|
{
|
|
name: "test2",
|
|
args: args{
|
|
ip: "103.197.70.244",
|
|
},
|
|
want: "香港",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := GetIPLoc(tt.args.ip); got != tt.want {
|
|
t.Errorf("GetIPLoc() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|