mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Add missing case for IntOrString unit tests
This commit is contained in:
		@@ -18,6 +18,7 @@ package util
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"gopkg.in/v1/yaml"
 | 
						"gopkg.in/v1/yaml"
 | 
				
			||||||
@@ -171,6 +172,33 @@ func TestIntOrStringMarshalJSON(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestIntOrStringMarshalJSONUnmarshalYAML(t *testing.T) {
 | 
				
			||||||
 | 
						cases := []struct {
 | 
				
			||||||
 | 
							input IntOrString
 | 
				
			||||||
 | 
						}{
 | 
				
			||||||
 | 
							{IntOrString{Kind: IntstrInt, IntVal: 123}},
 | 
				
			||||||
 | 
							{IntOrString{Kind: IntstrString, StrVal: "123"}},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, c := range cases {
 | 
				
			||||||
 | 
							input := IntOrStringHolder{c.input}
 | 
				
			||||||
 | 
							jsonMarshalled, err := json.Marshal(&input)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								t.Errorf("1: Failed to marshal input: '%v': %v", input, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var result IntOrStringHolder
 | 
				
			||||||
 | 
							err = yaml.Unmarshal(jsonMarshalled, &result)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								t.Errorf("2: Failed to unmarshall '%+v': %v", string(jsonMarshalled), err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if !reflect.DeepEqual(input, result) {
 | 
				
			||||||
 | 
								t.Errorf("3: Failed to marshal input '%+v': got %+v", input, result)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestStringDiff(t *testing.T) {
 | 
					func TestStringDiff(t *testing.T) {
 | 
				
			||||||
	diff := StringDiff("aaabb", "aaacc")
 | 
						diff := StringDiff("aaabb", "aaacc")
 | 
				
			||||||
	expect := "aaa\n\nA: bb\n\nB: cc\n\n"
 | 
						expect := "aaa\n\nA: bb\n\nB: cc\n\n"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user