github.com/qsis/helm@v3.0.0-beta.3+incompatible/pkg/releaseutil/manifest_test.go (about)

     1  /*
     2  Copyright The Helm Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package releaseutil // import "helm.sh/helm/pkg/releaseutil"
    18  
    19  import (
    20  	"reflect"
    21  	"testing"
    22  )
    23  
    24  const mockManifestFile = `
    25  
    26  ---
    27  apiVersion: v1
    28  kind: Pod
    29  metadata:
    30    name: finding-nemo,
    31    annotations:
    32      "helm.sh/hook": test
    33  spec:
    34    containers:
    35    - name: nemo-test
    36      image: fake-image
    37      cmd: fake-command
    38  `
    39  
    40  const expectedManifest = `apiVersion: v1
    41  kind: Pod
    42  metadata:
    43    name: finding-nemo,
    44    annotations:
    45      "helm.sh/hook": test
    46  spec:
    47    containers:
    48    - name: nemo-test
    49      image: fake-image
    50      cmd: fake-command`
    51  
    52  func TestSplitManifest(t *testing.T) {
    53  	manifests := SplitManifests(mockManifestFile)
    54  	if len(manifests) != 1 {
    55  		t.Errorf("Expected 1 manifest, got %v", len(manifests))
    56  	}
    57  	expected := map[string]string{"manifest-0": expectedManifest}
    58  	if !reflect.DeepEqual(manifests, expected) {
    59  		t.Errorf("Expected %v, got %v", expected, manifests)
    60  	}
    61  }