feat(testing): revisit telegraf config tests for filtering/restricting by org
parent
ff820d5a3d
commit
c720393c45
|
@ -18,10 +18,6 @@ const (
|
|||
dashThreeID = "020f755c3c082002"
|
||||
)
|
||||
|
||||
func idPtr(id platform.ID) *platform.ID {
|
||||
return &id
|
||||
}
|
||||
|
||||
func int32Ptr(i int32) *int32 {
|
||||
return &i
|
||||
}
|
||||
|
|
|
@ -115,16 +115,34 @@ func CreateTelegrafConfig(
|
|||
args args
|
||||
wants wants
|
||||
}{
|
||||
{
|
||||
name: "create telegraf config without organization ID should error",
|
||||
fields: TelegrafConfigFields{
|
||||
IDGenerator: mock.NewIDGenerator(oneID, t),
|
||||
TelegrafConfigs: []*platform.TelegrafConfig{},
|
||||
UserResourceMappings: []*platform.UserResourceMapping{},
|
||||
},
|
||||
args: args{
|
||||
telegrafConfig: &platform.TelegrafConfig{},
|
||||
},
|
||||
wants: wants{
|
||||
err: &platform.Error{
|
||||
Code: platform.EEmptyValue,
|
||||
Msg: platform.ErrTelegrafConfigInvalidOrganizationID,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "create telegraf config with empty set",
|
||||
fields: TelegrafConfigFields{
|
||||
IDGenerator: &loopIDGenerator{s: []string{oneID, twoID}},
|
||||
IDGenerator: mock.NewIDGenerator(oneID, t),
|
||||
TelegrafConfigs: []*platform.TelegrafConfig{},
|
||||
UserResourceMappings: []*platform.UserResourceMapping{},
|
||||
},
|
||||
args: args{
|
||||
userID: MustIDBase16(threeID),
|
||||
telegrafConfig: &platform.TelegrafConfig{
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "name1",
|
||||
Agent: platform.TelegrafAgentConfig{
|
||||
Interval: 1000,
|
||||
|
@ -158,6 +176,7 @@ func CreateTelegrafConfig(
|
|||
telegrafs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "name1",
|
||||
Agent: platform.TelegrafAgentConfig{
|
||||
Interval: 1000,
|
||||
|
@ -188,6 +207,7 @@ func CreateTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc1",
|
||||
Agent: platform.TelegrafAgentConfig{
|
||||
Interval: 4000,
|
||||
|
@ -212,6 +232,7 @@ func CreateTelegrafConfig(
|
|||
args: args{
|
||||
userID: MustIDBase16(threeID),
|
||||
telegrafConfig: &platform.TelegrafConfig{
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "name2",
|
||||
Agent: platform.TelegrafAgentConfig{
|
||||
Interval: 1001,
|
||||
|
@ -237,6 +258,7 @@ func CreateTelegrafConfig(
|
|||
telegrafs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc1",
|
||||
Agent: platform.TelegrafAgentConfig{
|
||||
Interval: 4000,
|
||||
|
@ -250,6 +272,7 @@ func CreateTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "name2",
|
||||
Agent: platform.TelegrafAgentConfig{
|
||||
Interval: 1001,
|
||||
|
@ -308,10 +331,13 @@ func CreateTelegrafConfig(
|
|||
}
|
||||
}
|
||||
|
||||
tcs, _, err := s.FindTelegrafConfigs(ctx, platform.UserResourceMappingFilter{
|
||||
filter := platform.TelegrafConfigFilter{
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
UserID: MustIDBase16(threeID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
})
|
||||
},
|
||||
}
|
||||
tcs, _, err := s.FindTelegrafConfigs(ctx, filter)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to retrieve telegraf configs: %v", err)
|
||||
}
|
||||
|
@ -358,6 +384,7 @@ func FindTelegrafConfigByID(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -367,6 +394,7 @@ func FindTelegrafConfigByID(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -399,6 +427,7 @@ func FindTelegrafConfigByID(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -408,6 +437,7 @@ func FindTelegrafConfigByID(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -440,6 +470,7 @@ func FindTelegrafConfigByID(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -449,6 +480,7 @@ func FindTelegrafConfigByID(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -471,6 +503,7 @@ func FindTelegrafConfigByID(
|
|||
wants: wants{
|
||||
telegrafConfig: &platform.TelegrafConfig{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -517,7 +550,7 @@ func FindTelegrafConfig(
|
|||
t *testing.T,
|
||||
) {
|
||||
type args struct {
|
||||
filter platform.UserResourceMappingFilter
|
||||
filter platform.TelegrafConfigFilter
|
||||
}
|
||||
|
||||
type wants struct {
|
||||
|
@ -550,6 +583,7 @@ func FindTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -559,6 +593,7 @@ func FindTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -576,16 +611,18 @@ func FindTelegrafConfig(
|
|||
},
|
||||
},
|
||||
args: args{
|
||||
filter: platform.UserResourceMappingFilter{
|
||||
filter: platform.TelegrafConfigFilter{
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
UserID: MustIDBase16(threeID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
UserType: platform.Member,
|
||||
},
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
telegrafConfig: &platform.TelegrafConfig{
|
||||
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -622,6 +659,7 @@ func FindTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -631,6 +669,7 @@ func FindTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -648,11 +687,13 @@ func FindTelegrafConfig(
|
|||
},
|
||||
},
|
||||
args: args{
|
||||
filter: platform.UserResourceMappingFilter{
|
||||
filter: platform.TelegrafConfigFilter{
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
UserID: MustIDBase16(fourID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
},
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
err: &platform.Error{
|
||||
Code: platform.ENotFound,
|
||||
|
@ -671,7 +712,6 @@ func FindTelegrafConfig(
|
|||
if err != nil && tt.wants.err == nil {
|
||||
t.Fatalf("expected errors to be nil got '%v'", err)
|
||||
}
|
||||
|
||||
if err != nil && tt.wants.err != nil {
|
||||
if platform.ErrorCode(err) != platform.ErrorCode(tt.wants.err) {
|
||||
t.Fatalf("expected error '%v' got '%v'", tt.wants.err, err)
|
||||
|
@ -690,7 +730,7 @@ func FindTelegrafConfigs(
|
|||
t *testing.T,
|
||||
) {
|
||||
type args struct {
|
||||
filter platform.UserResourceMappingFilter
|
||||
filter platform.TelegrafConfigFilter
|
||||
}
|
||||
|
||||
type wants struct {
|
||||
|
@ -704,16 +744,18 @@ func FindTelegrafConfigs(
|
|||
wants wants
|
||||
}{
|
||||
{
|
||||
name: "find nothing",
|
||||
name: "find nothing (empty set)",
|
||||
fields: TelegrafConfigFields{
|
||||
UserResourceMappings: []*platform.UserResourceMapping{},
|
||||
TelegrafConfigs: []*platform.TelegrafConfig{},
|
||||
},
|
||||
args: args{
|
||||
filter: platform.UserResourceMappingFilter{
|
||||
filter: platform.TelegrafConfigFilter{
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
Resource: platform.TelegrafsResource,
|
||||
},
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
telegrafConfigs: []*platform.TelegrafConfig{},
|
||||
},
|
||||
|
@ -738,6 +780,7 @@ func FindTelegrafConfigs(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -747,6 +790,7 @@ func FindTelegrafConfigs(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -764,15 +808,18 @@ func FindTelegrafConfigs(
|
|||
},
|
||||
},
|
||||
args: args{
|
||||
filter: platform.UserResourceMappingFilter{
|
||||
filter: platform.TelegrafConfigFilter{
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
UserID: MustIDBase16(threeID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
},
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
telegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -782,6 +829,7 @@ func FindTelegrafConfigs(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -819,6 +867,7 @@ func FindTelegrafConfigs(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -828,6 +877,7 @@ func FindTelegrafConfigs(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -845,16 +895,19 @@ func FindTelegrafConfigs(
|
|||
},
|
||||
},
|
||||
args: args{
|
||||
filter: platform.UserResourceMappingFilter{
|
||||
filter: platform.TelegrafConfigFilter{
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
UserID: MustIDBase16(threeID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
UserType: platform.Owner,
|
||||
},
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
telegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -865,6 +918,94 @@ func FindTelegrafConfigs(
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "find owners and restrict by organization",
|
||||
fields: TelegrafConfigFields{
|
||||
UserResourceMappings: []*platform.UserResourceMapping{
|
||||
{
|
||||
ResourceID: MustIDBase16(oneID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
UserID: MustIDBase16(threeID),
|
||||
UserType: platform.Owner,
|
||||
},
|
||||
{
|
||||
ResourceID: MustIDBase16(twoID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
UserID: MustIDBase16(threeID),
|
||||
UserType: platform.Member,
|
||||
},
|
||||
{
|
||||
ResourceID: MustIDBase16(fourID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
UserID: MustIDBase16(threeID),
|
||||
UserType: platform.Owner,
|
||||
},
|
||||
},
|
||||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
Config: &inputs.CPUStats{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
Comment: "comment1",
|
||||
Config: &inputs.File{
|
||||
Files: []string{"f1", "f2"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Comment: "comment2",
|
||||
Config: &inputs.MemStats{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(fourID),
|
||||
OrganizationID: MustIDBase16(oneID),
|
||||
Name: "tc3",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
Config: &inputs.CPUStats{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
filter: platform.TelegrafConfigFilter{
|
||||
OrganizationID: idPtr(MustIDBase16(oneID)),
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
UserID: MustIDBase16(threeID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
UserType: platform.Owner,
|
||||
},
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
telegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(fourID),
|
||||
OrganizationID: MustIDBase16(oneID),
|
||||
Name: "tc3",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
Config: &inputs.CPUStats{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "find nothing",
|
||||
fields: TelegrafConfigFields{
|
||||
|
@ -885,6 +1026,7 @@ func FindTelegrafConfigs(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -894,6 +1036,7 @@ func FindTelegrafConfigs(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -911,11 +1054,13 @@ func FindTelegrafConfigs(
|
|||
},
|
||||
},
|
||||
args: args{
|
||||
filter: platform.UserResourceMappingFilter{
|
||||
filter: platform.TelegrafConfigFilter{
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
UserID: MustIDBase16(fourID),
|
||||
Resource: platform.TelegrafsResource,
|
||||
},
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
err: &platform.Error{
|
||||
Code: platform.ENotFound,
|
||||
|
@ -978,6 +1123,7 @@ func UpdateTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -987,6 +1133,7 @@ func UpdateTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1035,6 +1182,7 @@ func UpdateTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1044,6 +1192,7 @@ func UpdateTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1064,6 +1213,7 @@ func UpdateTelegrafConfig(
|
|||
userID: MustIDBase16(fourID),
|
||||
id: MustIDBase16(twoID),
|
||||
telegrafConfig: &platform.TelegrafConfig{
|
||||
OrganizationID: MustIDBase16(oneID), // notice this get ignored - ie., resulting TelegrafConfig will have OrganizationID equal to fourID
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1080,6 +1230,7 @@ func UpdateTelegrafConfig(
|
|||
wants: wants{
|
||||
telegrafConfig: &platform.TelegrafConfig{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1100,6 +1251,7 @@ func UpdateTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(oneID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1109,6 +1261,7 @@ func UpdateTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(oneID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1161,6 +1314,7 @@ func UpdateTelegrafConfig(
|
|||
wants: wants{
|
||||
telegrafConfig: &platform.TelegrafConfig{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(oneID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1249,6 +1403,7 @@ func DeleteTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1258,6 +1413,7 @@ func DeleteTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1300,6 +1456,7 @@ func DeleteTelegrafConfig(
|
|||
telegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1309,6 +1466,7 @@ func DeleteTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(fourID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1346,6 +1504,7 @@ func DeleteTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1355,6 +1514,7 @@ func DeleteTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1396,6 +1556,7 @@ func DeleteTelegrafConfig(
|
|||
telegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1405,6 +1566,7 @@ func DeleteTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(threeID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1442,6 +1604,7 @@ func DeleteTelegrafConfig(
|
|||
TelegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1451,6 +1614,7 @@ func DeleteTelegrafConfig(
|
|||
},
|
||||
{
|
||||
ID: MustIDBase16(twoID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc2",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1483,6 +1647,7 @@ func DeleteTelegrafConfig(
|
|||
telegrafConfigs: []*platform.TelegrafConfig{
|
||||
{
|
||||
ID: MustIDBase16(oneID),
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
Name: "tc1",
|
||||
Plugins: []platform.TelegrafPlugin{
|
||||
{
|
||||
|
@ -1509,10 +1674,13 @@ func DeleteTelegrafConfig(
|
|||
t.Fatalf("expected error '%v' got '%v'", tt.wants.err, err)
|
||||
}
|
||||
}
|
||||
tcs, n, err := s.FindTelegrafConfigs(ctx, platform.UserResourceMappingFilter{
|
||||
filter := platform.TelegrafConfigFilter{
|
||||
UserResourceMappingFilter: platform.UserResourceMappingFilter{
|
||||
UserID: tt.args.userID,
|
||||
Resource: platform.TelegrafsResource,
|
||||
})
|
||||
},
|
||||
}
|
||||
tcs, n, err := s.FindTelegrafConfigs(ctx, filter)
|
||||
if err != nil && tt.wants.err == nil {
|
||||
t.Fatalf("expected errors to be nil got '%v'", err)
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@ func diffPlatformErrors(name string, actual, expected error, opPrefix string, t
|
|||
}
|
||||
}
|
||||
|
||||
func idPtr(id platform.ID) *platform.ID {
|
||||
return &id
|
||||
}
|
||||
|
||||
// MustIDBase16 is an helper to ensure a correct ID is built during testing.
|
||||
func MustIDBase16(s string) platform.ID {
|
||||
id, err := platform.IDFromString(s)
|
||||
|
|
Loading…
Reference in New Issue