mhoppa commented on a change in pull request #3930: Rewrite profile import to Go
URL: https://github.com/apache/trafficcontrol/pull/3930#discussion_r331624051
##########
File path: traffic_ops/testing/api/v14/profiles_test.go
##########
@@ -159,6 +161,69 @@ func GetTestProfiles(t *testing.T) {
}
}
+func ImportProfile(t *testing.T) {
+ // Get ID of Profile to export
+ resp, _, err := TOSession.GetProfileByName(testData.Profiles[0].Name)
+ if err != nil {
+ t.Fatalf("cannot GET Profile by name: %v - %v\n", err, resp)
+ }
+ if resp == nil {
+ t.Fatalf("error getting Profile: response nil\n")
+ }
+ if len(resp) != 1 {
+ t.Fatalf("Profiles expected 1, actual %v\n", len(resp))
+ }
+ profileID := resp[0].ID
+
+ // Export Profile to import
+ exportResp, _, err := TOSession.ExportProfile(profileID)
+ if err != nil {
+ t.Fatalf("error exporting Profile: %v - %v\n", profileID, err)
+ }
+ if exportResp == nil {
+ t.Fatalf("error exporting Profile: response nil\n")
+ }
+
+ // Modify Profile and import
+
+ // Add parameter and change name
+ profile := exportResp.Profile
+ profile.Name = util.StrPtr("TestProfileImport")
+
+ newParam := tc.ProfileExportImportParameterNullable{
+ ConfigFile: util.StrPtr("config_file_import_test"),
+ Name: util.StrPtr("param_import_test"),
+ Value: util.StrPtr("import_test"),
+ }
+ parameters := append(exportResp.Parameters, newParam)
+ // Import Profile
+ importReq := tc.ProfileImportRequest{
+ Profile: profile,
+ Parameters: parameters,
+ }
+ importResp, _, err := TOSession.ImportProfile(&importReq)
+ if err != nil {
+ t.Fatalf("error importing Profile: %v - %v\n", profileID, err)
Review comment:
😕 this worked locally for me let me rerun. Thanks for testing it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services