-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Generics in TO Integration Tests (#7144)
* Add generic pointer function * Use generics and clean up * undo accidental format * use generic ptr func * fix typo * use generic ptr func * updated tests to use generics * created own test file for the new route * Add license * fix error * Updated tests to use generics * Updated v5 tests to use generics * undo format
- Loading branch information
1 parent
bd6f7ee
commit 736b5d5
Showing
73 changed files
with
1,871 additions
and
2,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
traffic_ops/testing/api/v4/multiple_server_capabilities_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package v4 | ||
|
||
/* | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/apache/trafficcontrol/lib/go-tc" | ||
"github.com/apache/trafficcontrol/traffic_ops/testing/api/utils" | ||
client "github.com/apache/trafficcontrol/traffic_ops/v4-client" | ||
) | ||
|
||
func TestMultipleServerCapabilities(t *testing.T) { | ||
WithObjs(t, []TCObj{CDNs, Types, Tenants, Parameters, Profiles, Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, ServerCapabilities, ServerServerCapabilities}, func() { | ||
|
||
methodTests := utils.TestCase[client.Session, client.RequestOptions, tc.MultipleServerCapabilities]{ | ||
"PUT": { | ||
"OK when VALID REQUEST": { | ||
ClientSession: TOSession, | ||
RequestBody: tc.MultipleServerCapabilities{ | ||
ServerID: GetServerID(t, "dtrc-mid-04")(), | ||
ServerCapabilities: []string{"disk", "blah"}, | ||
}, | ||
Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)), | ||
}, | ||
}, | ||
} | ||
|
||
for method, testCases := range methodTests { | ||
t.Run(method, func(t *testing.T) { | ||
for name, testCase := range testCases { | ||
switch method { | ||
case "PUT": | ||
t.Run(name, func(t *testing.T) { | ||
alerts, reqInf, err := testCase.ClientSession.AssignMultipleServerCapability(testCase.RequestBody, testCase.RequestOpts, testCase.RequestBody.ServerID) | ||
for _, check := range testCase.Expectations { | ||
check(t, reqInf, nil, alerts, err) | ||
} | ||
}) | ||
} | ||
} | ||
}) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.