master
1package utils
2
3import (
4 "testing"
5)
6
7func TestSetURL(t *testing.T) {
8 tests := []struct {
9 name string
10 args []string
11 expected string
12 }{
13 {
14 name: "valid URL from args",
15 args: []string{"https://example.com"},
16 expected: "https://example.com",
17 },
18 {
19 name: "empty args returns empty or exits",
20 args: []string{},
21 expected: "", // Will exit in actual code, but we can't test that easily
22 },
23 }
24
25 for _, tt := range tests {
26 t.Run(tt.name, func(t *testing.T) {
27 if len(tt.args) > 0 {
28 result := SetURL(tt.args)
29 if result != tt.expected {
30 t.Errorf("SetURL() = %v, want %v", result, tt.expected)
31 }
32 }
33 })
34 }
35}
36
37func TestSetIP(t *testing.T) {
38 tests := []struct {
39 name string
40 args []string
41 expected string
42 }{
43 {
44 name: "valid IP from args",
45 args: []string{"192.168.1.1"},
46 expected: "192.168.1.1",
47 },
48 {
49 name: "empty args returns empty",
50 args: []string{},
51 expected: "",
52 },
53 }
54
55 for _, tt := range tests {
56 t.Run(tt.name, func(t *testing.T) {
57 result := SetIP(tt.args)
58 if result != tt.expected {
59 t.Errorf("SetIP() = %v, want %v", result, tt.expected)
60 }
61 })
62 }
63}