MCPcopy Index your code
hub / github.com/docker/cli / TestResourceOptionsToResourceRequirements

Function TestResourceOptionsToResourceRequirements

cli/command/service/opts_test.go:150–187  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func TestResourceOptionsToResourceRequirements(t *testing.T) {
151 incorrectOptions := []resourceOptions{
152 {
153 resGenericResources: []string{"foo=bar", "foo=1"},
154 },
155 {
156 resGenericResources: []string{"foo=bar", "foo=baz"},
157 },
158 {
159 resGenericResources: []string{"foo=bar"},
160 },
161 {
162 resGenericResources: []string{"foo=1", "foo=2"},
163 },
164 }
165
166 flags := newCreateCommand(nil).Flags()
167
168 for _, opt := range incorrectOptions {
169 _, err := opt.ToResourceRequirements(flags)
170 assert.Check(t, is.ErrorContains(err, ""))
171 }
172
173 correctOptions := []resourceOptions{
174 {
175 resGenericResources: []string{"foo=1"},
176 },
177 {
178 resGenericResources: []string{"foo=1", "bar=2"},
179 },
180 }
181
182 for _, opt := range correctOptions {
183 r, err := opt.ToResourceRequirements(flags)
184 assert.NilError(t, err)
185 assert.Check(t, is.Len(r.Reservations.GenericResources, len(opt.resGenericResources)))
186 }
187}
188
189func TestResourceOptionsToResourceRequirementsSwap(t *testing.T) {
190 // first, check that no flag set means no field set in the return

Callers

nothing calls this directly

Calls 3

newCreateCommandFunction · 0.70
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…