ocket8888 commented on a change in pull request #5179: URL: https://github.com/apache/trafficcontrol/pull/5179#discussion_r583875533
########## File path: traffic_ops/testing/api/v4/cdnnotifications_test.go ########## @@ -0,0 +1,61 @@ +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 ( + "github.com/apache/trafficcontrol/lib/go-tc" + "testing" +) + +func TestCDNNotifications(t *testing.T) { + WithObjs(t, []TCObj{CDNs, CDNNotifications}, func() { + GetTestCDNotifications(t) + }) +} + +func GetTestCDNotifications(t *testing.T) { + for _, cdn := range testData.CDNs { + resp, _, err := TOSession.GetCDNNotifications(cdn.Name, nil) + if err != nil { + t.Errorf("cannot GET cdn notification for cdn: %v - %v", err, resp) + } + if len(resp) > 0 { + respNotification := resp[0] + expectedNotification := "test notification: " + cdn.Name + if *respNotification.Notification != expectedNotification { Review comment: This will segfault if the CDN has no notification, should check `respNotification.Notification != nil` first ########## File path: traffic_ops/v4-client/cdn_notifications.go ########## @@ -0,0 +1,55 @@ +/* + + 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. +*/ + +package client + +import ( + "fmt" + "github.com/apache/trafficcontrol/lib/go-tc" + "github.com/apache/trafficcontrol/traffic_ops/toclientlib" + "net/http" + "net/url" Review comment: standard library imports should be grouped before project-local imports ########## File path: traffic_ops/testing/api/v4/cdnnotifications_test.go ########## @@ -0,0 +1,61 @@ +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 ( + "github.com/apache/trafficcontrol/lib/go-tc" + "testing" Review comment: standard library imports should be grouped before project-local imports ---------------------------------------------------------------- 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]
