github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/internal/env/ip_test.go (about) 1 package env_test 2 3 import ( 4 "testing" 5 6 "github.com/quickfeed/quickfeed/internal/env" 7 ) 8 9 func TestIsLocal(t *testing.T) { 10 tests := []struct { 11 name string 12 ip string 13 want bool 14 }{ 15 {"localhost", "localhost", true}, 16 {"loopback", "127.0.0.1", true}, 17 {"private", "172.31.120.166", true}, 18 {"public", "84.22.1.92", false}, 19 } 20 21 for _, tt := range tests { 22 t.Run(tt.name, func(t *testing.T) { 23 got := env.IsLocal(tt.ip) 24 if got != tt.want { 25 t.Errorf("isLocal(%q) = %v, want %v", tt.ip, got, tt.want) 26 } 27 }) 28 } 29 }