MCPcopy
hub / github.com/lxc/incus / TestProject

Function TestProject

shared/api/url_test.go:121–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestProject(t *testing.T) {
122 tests := []struct {
123 name string
124 projectName string
125 shouldHaveQuery bool
126 expectedValue string
127 }{
128 {
129 name: "empty project name",
130 projectName: "",
131 shouldHaveQuery: false,
132 },
133 {
134 name: "default project",
135 projectName: "default",
136 shouldHaveQuery: false,
137 },
138 {
139 name: "custom project",
140 projectName: "my-project",
141 shouldHaveQuery: true,
142 expectedValue: "my-project",
143 },
144 }
145
146 for _, tt := range tests {
147 t.Run(tt.name, func(t *testing.T) {
148 u := NewURL().Project(tt.projectName)
149 query := u.Query()
150
151 if tt.shouldHaveQuery {
152 if !query.Has("project") {
153 t.Error("Expected query to have 'project' parameter")
154 }
155
156 if query.Get("project") != tt.expectedValue {
157 t.Errorf("Expected project value %q, got %q", tt.expectedValue, query.Get("project"))
158 }
159 } else {
160 if query.Has("project") {
161 t.Errorf("Expected query to not have 'project' parameter, but got %q", query.Get("project"))
162 }
163 }
164 })
165 }
166}
167
168func TestTarget(t *testing.T) {
169 tests := []struct {

Callers

nothing calls this directly

Calls 6

NewURLFunction · 0.85
ErrorfMethod · 0.80
ProjectMethod · 0.65
ErrorMethod · 0.65
GetMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…