@@ -7,14 +7,19 @@ import (
77
88// MockLintContext is mock implementation of the LintContext used in unit tests
99type MockLintContext struct {
10- objects map [string ]k8sutil.Object
10+ objects map [string ]k8sutil.Object
11+ rawObjects map [string ][]byte
1112}
1213
1314// Objects returns all the objects under this MockLintContext
1415func (l * MockLintContext ) Objects () []lintcontext.Object {
1516 result := make ([]lintcontext.Object , 0 , len (l .objects ))
16- for _ , p := range l .objects {
17- result = append (result , lintcontext.Object {Metadata : lintcontext.ObjectMetadata {}, K8sObject : p })
17+ for key , p := range l .objects {
18+ metadata := lintcontext.ObjectMetadata {}
19+ if raw , ok := l .rawObjects [key ]; ok {
20+ metadata .Raw = raw
21+ }
22+ result = append (result , lintcontext.Object {Metadata : metadata , K8sObject : p })
1823 }
1924 return result
2025}
@@ -26,10 +31,19 @@ func (l *MockLintContext) InvalidObjects() []lintcontext.InvalidObject {
2631
2732// NewMockContext returns an empty mockLintContext
2833func NewMockContext () * MockLintContext {
29- return & MockLintContext {objects : make (map [string ]k8sutil.Object )}
34+ return & MockLintContext {
35+ objects : make (map [string ]k8sutil.Object ),
36+ rawObjects : make (map [string ][]byte ),
37+ }
3038}
3139
3240// AddObject adds an object to the MockLintContext
3341func (l * MockLintContext ) AddObject (key string , obj k8sutil.Object ) {
3442 l .objects [key ] = obj
3543}
44+
45+ // AddObjectWithRaw adds an object to the MockLintContext with raw YAML data
46+ func (l * MockLintContext ) AddObjectWithRaw (key string , obj k8sutil.Object , raw []byte ) {
47+ l .objects [key ] = obj
48+ l .rawObjects [key ] = raw
49+ }
0 commit comments