Skip to content

Commit

Permalink
Add a few tests to ensure that bracketed fieldsa are useable in move …
Browse files Browse the repository at this point in the history
…operator (#230)
  • Loading branch information
djaglowski authored Jul 29, 2021
1 parent eb114e5 commit 168117d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
9 changes: 9 additions & 0 deletions operator/builtin/transformer/move/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ func TestGoldenConfig(t *testing.T) {
return cfg
}(),
},
{
Name: "MoveBracketedAttributeToResource",
Expect: func() *MoveOperatorConfig {
cfg := defaultCfg()
cfg.From = entry.NewAttributeField("dotted.field.name")
cfg.To = entry.NewResourceField("new")
return cfg
}(),
},
{
Name: "MoveResourceToAttribute",
Expect: func() *MoveOperatorConfig {
Expand Down
63 changes: 63 additions & 0 deletions operator/builtin/transformer/move/move_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,69 @@ func TestProcessAndBuild(t *testing.T) {
return e
},
},
{
"MoveBracketedAttributeToResource",
false,
func() *MoveOperatorConfig {
cfg := defaultCfg()
cfg.From = entry.NewAttributeField("dotted.field.name")
cfg.To = entry.NewResourceField("new")
return cfg
}(),
func() *entry.Entry {
e := newTestEntry()
e.Attributes = map[string]string{"dotted.field.name": "val"}
return e
},
func() *entry.Entry {
e := newTestEntry()
e.Resource = map[string]string{"new": "val"}
e.Attributes = map[string]string{}
return e
},
},
{
"MoveBracketedAttributeToBracketedResource",
false,
func() *MoveOperatorConfig {
cfg := defaultCfg()
cfg.From = entry.NewAttributeField("dotted.field.name")
cfg.To = entry.NewResourceField("dotted.field.name")
return cfg
}(),
func() *entry.Entry {
e := newTestEntry()
e.Attributes = map[string]string{"dotted.field.name": "val"}
return e
},
func() *entry.Entry {
e := newTestEntry()
e.Resource = map[string]string{"dotted.field.name": "val"}
e.Attributes = map[string]string{}
return e
},
},
{
"MoveAttributeToBracketedResource",
false,
func() *MoveOperatorConfig {
cfg := defaultCfg()
cfg.From = entry.NewAttributeField("new")
cfg.To = entry.NewResourceField("dotted.field.name")
return cfg
}(),
func() *entry.Entry {
e := newTestEntry()
e.Attributes = map[string]string{"new": "val"}
return e
},
func() *entry.Entry {
e := newTestEntry()
e.Resource = map[string]string{"dotted.field.name": "val"}
e.Attributes = map[string]string{}
return e
},
},
{
"MoveResourceToAttribute",
false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type: move
from: $attributes["dotted.field.name"]
to: $resource.new

0 comments on commit 168117d

Please sign in to comment.