Skip to content

Commit

Permalink
fn command failing unmarshal test
Browse files Browse the repository at this point in the history
  • Loading branch information
shanalily committed Feb 9, 2022
1 parent a4238ac commit ad9d019
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 11 additions & 0 deletions kyaml/fn/framework/command/command_test.go
Expand Up @@ -5,6 +5,7 @@ package command_test

import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -66,6 +67,7 @@ ENTRYPOINT ["function"]
func TestCommand_standalone(t *testing.T) {
var config struct {
A string `json:"a" yaml:"a"`
B int `json:"b" yaml:"b"`
}

fn := func(items []*yaml.RNode) ([]*yaml.RNode, error) {
Expand All @@ -83,6 +85,10 @@ metadata:
if err != nil {
return nil, err
}
err = items[i].PipeE(yaml.SetAnnotation("b", fmt.Sprintf("%v", config.B)))
if err != nil {
return nil, err
}
}

return items, nil
Expand All @@ -99,6 +105,7 @@ metadata:
func TestCommand_standalone_stdin(t *testing.T) {
var config struct {
A string `json:"a" yaml:"a"`
B int `json:"b" yaml:"b"`
}

p := &framework.SimpleProcessor{
Expand All @@ -119,6 +126,10 @@ metadata:
if err != nil {
return nil, err
}
err = items[i].PipeE(yaml.SetAnnotation("b", fmt.Sprintf("%v", config.B)))
if err != nil {
return nil, err
}
}

return items, nil
Expand Down
3 changes: 2 additions & 1 deletion kyaml/fn/framework/command/testdata/standalone/config.yaml
Expand Up @@ -3,4 +3,5 @@

apiVersion: example.com/v1alpha1
kind: Foo
a: b
a: c
b: d
6 changes: 4 additions & 2 deletions kyaml/fn/framework/command/testdata/standalone/expected.yaml
Expand Up @@ -8,7 +8,8 @@ metadata:
namespace: default
annotations:
foo: bar2
a: 'b'
a: 'c'
b: 'd'
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -17,4 +18,5 @@ metadata:
namespace: default
annotations:
foo: bar1
a: 'b'
a: 'c'
b: 'd'

0 comments on commit ad9d019

Please sign in to comment.