You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/04/10 18:22:13 UTC
[incubator-trafficcontrol] 07/07: added a test case to check that a
Profile with Parameters gets retrieved
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
commit 5bbf52b2b5fdb401daaeda6ac0d478966a3acb60
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Fri Apr 6 13:47:30 2018 -0600
added a test case to check that a Profile with Parameters gets retrieved
uncommented the deletes
---
traffic_ops/client/v13/profile.go | 17 +++++++++--------
traffic_ops/testing/api/v13/profiles_test.go | 24 ++++++++++++++++++++++++
traffic_ops/testing/api/v13/traffic_control.go | 2 +-
3 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/traffic_ops/client/v13/profile.go b/traffic_ops/client/v13/profile.go
index bbcc799..dba1b12 100644
--- a/traffic_ops/client/v13/profile.go
+++ b/traffic_ops/client/v13/profile.go
@@ -23,6 +23,7 @@ import (
"net/url"
"github.com/apache/incubator-trafficcontrol/lib/go-tc"
+ "github.com/apache/incubator-trafficcontrol/lib/go-tc/v13"
)
const (
@@ -30,7 +31,7 @@ const (
)
// Create a Profile
-func (to *Session) CreateProfile(pl tc.Profile) (tc.Alerts, ReqInf, error) {
+func (to *Session) CreateProfile(pl v13.Profile) (tc.Alerts, ReqInf, error) {
var remoteAddr net.Addr
reqBody, err := json.Marshal(pl)
@@ -49,7 +50,7 @@ func (to *Session) CreateProfile(pl tc.Profile) (tc.Alerts, ReqInf, error) {
}
// Update a Profile by ID
-func (to *Session) UpdateProfileByID(id int, pl tc.Profile) (tc.Alerts, ReqInf, error) {
+func (to *Session) UpdateProfileByID(id int, pl v13.Profile) (tc.Alerts, ReqInf, error) {
var remoteAddr net.Addr
reqBody, err := json.Marshal(pl)
@@ -69,7 +70,7 @@ func (to *Session) UpdateProfileByID(id int, pl tc.Profile) (tc.Alerts, ReqInf,
}
// Returns a list of Profiles
-func (to *Session) GetProfiles() ([]tc.Profile, ReqInf, error) {
+func (to *Session) GetProfiles() ([]v13.Profile, ReqInf, error) {
resp, remoteAddr, err := to.request(http.MethodGet, API_v13_Profiles, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
@@ -77,13 +78,13 @@ func (to *Session) GetProfiles() ([]tc.Profile, ReqInf, error) {
}
defer resp.Body.Close()
- var data tc.ProfilesResponse
+ var data v13.ProfilesResponse
err = json.NewDecoder(resp.Body).Decode(&data)
return data.Response, reqInf, nil
}
// GET a Profile by the Profile ID
-func (to *Session) GetProfileByID(id int) ([]tc.Profile, ReqInf, error) {
+func (to *Session) GetProfileByID(id int) ([]v13.Profile, ReqInf, error) {
route := fmt.Sprintf("%s/%d", API_v13_Profiles, id)
resp, remoteAddr, err := to.request(http.MethodGet, route, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
@@ -92,7 +93,7 @@ func (to *Session) GetProfileByID(id int) ([]tc.Profile, ReqInf, error) {
}
defer resp.Body.Close()
- var data tc.ProfilesResponse
+ var data v13.ProfilesResponse
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
return nil, reqInf, err
}
@@ -101,7 +102,7 @@ func (to *Session) GetProfileByID(id int) ([]tc.Profile, ReqInf, error) {
}
// GET a Profile by the Profile name
-func (to *Session) GetProfileByName(name string) ([]tc.Profile, ReqInf, error) {
+func (to *Session) GetProfileByName(name string) ([]v13.Profile, ReqInf, error) {
URI := API_v13_Profiles + "?name=" + url.QueryEscape(name)
resp, remoteAddr, err := to.request(http.MethodGet, URI, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
@@ -110,7 +111,7 @@ func (to *Session) GetProfileByName(name string) ([]tc.Profile, ReqInf, error) {
}
defer resp.Body.Close()
- var data tc.ProfilesResponse
+ var data v13.ProfilesResponse
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
return nil, reqInf, err
}
diff --git a/traffic_ops/testing/api/v13/profiles_test.go b/traffic_ops/testing/api/v13/profiles_test.go
index 50ee4ab..94677f8 100644
--- a/traffic_ops/testing/api/v13/profiles_test.go
+++ b/traffic_ops/testing/api/v13/profiles_test.go
@@ -28,8 +28,11 @@ func TestProfiles(t *testing.T) {
CreateTestTypes(t)
CreateTestProfiles(t)
CreateTestParameters(t)
+ CreateTestProfileParameters(t)
UpdateTestProfiles(t)
GetTestProfiles(t)
+ GetTestProfilesWithParameters(t)
+ DeleteTestProfileParameters(t)
DeleteTestParameters(t)
DeleteTestProfiles(t)
DeleteTestTypes(t)
@@ -92,6 +95,27 @@ func GetTestProfiles(t *testing.T) {
}
}
}
+func GetTestProfilesWithParameters(t *testing.T) {
+ firstProfile := testData.Profiles[0]
+ resp, _, err := TOSession.GetProfileByName(firstProfile.Name)
+ if len(resp) > 0 {
+ respProfile := resp[0]
+ resp, _, err := TOSession.GetProfileByID(respProfile.ID)
+ if err != nil {
+ t.Errorf("cannot GET Profile by name: %v - %v\n", err, resp)
+ }
+ if len(resp) > 0 {
+ respProfile = resp[0]
+ respParameters := respProfile.Parameters
+ if len(respParameters) == 0 {
+ t.Errorf("expected a profile with parameters to be retrieved: %v - %v\n", err, respParameters)
+ }
+ }
+ }
+ if err != nil {
+ t.Errorf("cannot GET Profile by name: %v - %v\n", err, resp)
+ }
+}
func DeleteTestProfiles(t *testing.T) {
diff --git a/traffic_ops/testing/api/v13/traffic_control.go b/traffic_ops/testing/api/v13/traffic_control.go
index f21198b..015089e 100644
--- a/traffic_ops/testing/api/v13/traffic_control.go
+++ b/traffic_ops/testing/api/v13/traffic_control.go
@@ -29,7 +29,7 @@ type TrafficControl struct {
DeliveryServiceRequestComments []v12.DeliveryServiceRequestComment `json:"deliveryServiceRequestComments"`
DeliveryServices []v12.DeliveryService `json:"deliveryservices"`
Divisions []v12.Division `json:"divisions"`
- Profiles []v12.Profile `json:"profiles"`
+ Profiles []v13.Profile `json:"profiles"`
Parameters []v12.Parameter `json:"parameters"`
ProfileParameters []v13.ProfileParameter `json:"profileParameters"`
PhysLocations []v12.PhysLocation `json:"physLocations"`
--
To stop receiving notification emails like this one, please contact
dangogh@apache.org.