Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: use pointers in struct fields #90

Merged
merged 29 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
170e5ac
feat: add primitive types wrapper funtions
raul-te May 16, 2022
f547490
refactor(http)!: use pointers in struct fields
raul-te May 16, 2022
c121f39
refactor(agent_agent)!: use pointers in struct fields
raul-te May 16, 2022
f9fbf30
refactor(account_groups)!: use pointers in struct fields
raul-te May 16, 2022
6fd7939
refactor(agent)!: use pointers in struct fields
raul-te May 17, 2022
bda84f7
refactor(agent_server)!: use pointers in struct fields
raul-te May 17, 2022
1043058
fix: drop omitempty for alertRules
raul-te May 17, 2022
68ff29e
refactor(alert)!: use pointers in struct fields
raul-te May 17, 2022
742e6dc
refactor(bgp)!: use pointers in struct fields
raul-te May 17, 2022
6383f9e
refactor(bgp_monitor)!: use pointers in struct fields
raul-te May 17, 2022
b5a87e3
refactor(client)!: use pointers in struct fields
raul-te May 18, 2022
6023adc
refactor!: drop dnsp support
raul-te May 18, 2022
42e6a25
refactor(dnssec)!: use pointers in struct fields
raul-te May 18, 2022
f27598d
refactor(dns_server)!: use pointers in struct fields
raul-te May 18, 2022
0ec126e
refactor(dns_trace)!: use pointers in struct fields
raul-te May 19, 2022
72311d7
refactor(ftp_server)!: use pointers in struct fields
raul-te May 19, 2022
fc73d0d
refactor(group_label)!: use pointers in struct fields
raul-te May 19, 2022
319b2e4
refactor(integration)!: use pointers in struct fields
raul-te May 19, 2022
eb0f812
refactor(monitor)!: use pointers in struct fields
raul-te May 19, 2022
56cebb9
refactor(page_load)!: use pointers in struct fields
raul-te May 19, 2022
df83c31
refactor(role)!: use pointers in struct fields
raul-te May 19, 2022
ef565e8
refactor(sip_server)!: use pointers in struct fields
raul-te May 19, 2022
7d0939e
refactor(generic_test)!: use pointers in struct fields
raul-te May 19, 2022
4f70239
refactor(user)!: use pointers in struct fields
raul-te May 19, 2022
6044960
refactor(voice)!: use pointers in struct fields
raul-te May 19, 2022
e510c6b
refactor(voice_call)!: use pointers in struct fields
raul-te May 20, 2022
5cd3f47
refactor: int64 for TestID
raul-te May 20, 2022
a8f63d8
fix: restore AddAgent signature
raul-te May 20, 2022
d330bf2
fix(http_server): bogus omitempty
raul-te May 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(sip_server)!: use pointers in struct fields
  • Loading branch information
raul-te committed May 19, 2022
commit ef565e87985ac694a15d3243265bb478b7256adf
50 changes: 25 additions & 25 deletions sip_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@ import (
// SIPServer - SIPServer trace test
type SIPServer struct {
// Common test fields
AlertsEnabled int `json:"alertsEnabled,omitempty"`
AlertsEnabled *int `json:"alertsEnabled,omitempty"`
AlertRules []AlertRule `json:"alertRules"`
APILinks []APILink `json:"apiLinks,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
CreatedDate string `json:"createdDate,omitempty"`
Description string `json:"description,omitempty"`
Enabled int `json:"enabled,omitempty"`
CreatedBy *string `json:"createdBy,omitempty"`
CreatedDate *string `json:"createdDate,omitempty"`
Description *string `json:"description,omitempty"`
Enabled *int `json:"enabled,omitempty"`
Groups []GroupLabel `json:"groups,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedDate string `json:"modifiedDate,omitempty"`
SavedEvent int `json:"savedEvent,omitempty"`
ModifiedBy *string `json:"modifiedBy,omitempty"`
ModifiedDate *string `json:"modifiedDate,omitempty"`
SavedEvent *int `json:"savedEvent,omitempty"`
SharedWithAccounts []SharedWithAccount `json:"sharedWithAccounts,omitempty"`
TestID int `json:"testId,omitempty"`
TestName string `json:"testName,omitempty"`
Type string `json:"type,omitempty"`
LiveShare int `json:"liveShare,omitempty"`
TestID *int64 `json:"testId,omitempty"`
TestName *string `json:"testName,omitempty"`
Type *string `json:"type,omitempty"`
LiveShare *int `json:"liveShare,omitempty"`

// Fields unique to this test
Agents []Agent `json:"agents,omitempty"`
BandwidthMeasurements int `json:"bandwidthMeasurements,omitempty"`
BGPMeasurements int `json:"bgpMeasurements,omitempty"`
Interval int `json:"interval,omitempty"`
MTUMeasurements int `json:"mtuMeasurements,omitempty"`
NetworkMeasurements int `json:"networkMeasurements,omitempty"`
NumPathTraces int `json:"numPathTraces,omitempty"`
OptionsRegex string `json:"options_regex,omitempty"`
PathTraceMode string `json:"pathTraceMode,omitempty"`
ProbeMode string `json:"probeMode,omitempty"`
RegisterEnabled int `json:"registerEnabled,omitempty"`
SIPTargetTime int `json:"sipTargetTime,omitempty"`
SIPTimeLimit int `json:"sipTimeLimit,omitempty"`
BandwidthMeasurements *int `json:"bandwidthMeasurements,omitempty"`
BGPMeasurements *int `json:"bgpMeasurements,omitempty"`
Interval *int `json:"interval,omitempty"`
MTUMeasurements *int `json:"mtuMeasurements,omitempty"`
NetworkMeasurements *int `json:"networkMeasurements,omitempty"`
NumPathTraces *int `json:"numPathTraces,omitempty"`
OptionsRegex *string `json:"options_regex,omitempty"`
PathTraceMode *string `json:"pathTraceMode,omitempty"`
ProbeMode *string `json:"probeMode,omitempty"`
RegisterEnabled *int `json:"registerEnabled,omitempty"`
SIPTargetTime *int `json:"sipTargetTime,omitempty"`
SIPTimeLimit *int `json:"sipTimeLimit,omitempty"`
TargetSIPCredentials SIPAuthData `json:"targetSipCredentials,omitempty"`
UsePublicBGP int `json:"usePublicBgp,omitempty"`
UsePublicBGP *int `json:"usePublicBgp,omitempty"`
}

// AddAgent - Add agemt to sip server test
Expand Down
54 changes: 28 additions & 26 deletions sip_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ func TestClient_GetSIPServer(t *testing.T) {

// Define expected values from the API (based on the JSON we print out above)
expected := SIPServer{
TestID: 122621,
Enabled: 1,
CreatedBy: "William Fleming (wfleming@grumpysysadm.com)",
CreatedDate: "2020-02-06 15:28:07",
SavedEvent: 0,
AlertsEnabled: 1,
TestName: "test123",
Type: "sip-server",
Interval: 300,
TestID: Int64(122621),
Enabled: Int(1),
CreatedBy: String("William Fleming (wfleming@grumpysysadm.com)"),
CreatedDate: String("2020-02-06 15:28:07"),
SavedEvent: Int(0),
AlertsEnabled: Int(1),
TestName: String("test123"),
Type: String("sip-server"),
Interval: Int(300),
LiveShare: Int(0),
Agents: []Agent{
{
AgentID: Int(48620),
Expand Down Expand Up @@ -101,15 +102,16 @@ func TestClient_CreateSIPServer(t *testing.T) {
// Define expected values from the API (based on the JSON we print out above)
expected := SIPServer{

TestID: 122621,
Enabled: 1,
CreatedBy: "William Fleming (wfleming@grumpysysadm.com)",
CreatedDate: "2020-02-06 15:28:07",
SavedEvent: 0,
TestName: "test123",
Type: "sip-server",
Interval: 300,
AlertsEnabled: 1,
TestID: Int64(122621),
Enabled: Int(1),
CreatedBy: String("William Fleming (wfleming@grumpysysadm.com)"),
CreatedDate: String("2020-02-06 15:28:07"),
SavedEvent: Int(0),
TestName: String("test123"),
Type: String("sip-server"),
Interval: Int(300),
AlertsEnabled: Int(1),
LiveShare: Int(0),
Agents: []Agent{
{
AgentID: Int(48620),
Expand Down Expand Up @@ -153,8 +155,8 @@ func TestClient_CreateSIPServer(t *testing.T) {
},
}
create := SIPServer{
TestName: "test1",
Interval: 300,
TestName: String("test1"),
Interval: Int(300),
}
res, err := client.CreateSIPServer(create)
teardown()
Expand Down Expand Up @@ -190,26 +192,26 @@ func TestClient_UpdateSIPServer(t *testing.T) {
var client = &Client{APIEndpoint: server.URL, AuthToken: "foo"}
id := 1
sipS := SIPServer{
TestName: "test1",
TestName: String("test1"),
}
res, err := client.UpdateSIPServer(id, sipS)
if err != nil {
t.Fatal(err)
}
expected := SIPServer{TestID: 1, TestName: "test123", Type: "sip-server"}
expected := SIPServer{TestID: Int64(1), TestName: String("test123"), Type: String("sip-server")}
assert.Equal(t, &expected, res)

}

func TestSIPServer_AddAgent(t *testing.T) {
test := SIPServer{TestName: "test", Agents: Agents{}}
expected := SIPServer{TestName: "test", Agents: []Agent{{AgentID: Int(1)}}}
test := SIPServer{TestName: String("test"), Agents: Agents{}}
expected := SIPServer{TestName: String("test"), Agents: []Agent{{AgentID: Int(1)}}}
test.AddAgent(Int(1))
assert.Equal(t, expected, test)
}
func TestClient_AddSIPServerAlertRule(t *testing.T) {
test := SIPServer{TestName: "test", AlertRules: []AlertRule{}}
expected := SIPServer{TestName: "test", AlertRules: []AlertRule{{RuleID: Int(1)}}}
test := SIPServer{TestName: String("test"), AlertRules: []AlertRule{}}
expected := SIPServer{TestName: String("test"), AlertRules: []AlertRule{{RuleID: Int(1)}}}
test.AddAlertRule(1)
assert.Equal(t, expected, test)
}
Expand Down