github.com/darkowlzz/helm@v2.5.1-0.20171213183701-6707fe0468d4+incompatible/pkg/releaseutil/manifest_test.go (about)

     1  /*
     2  Copyright 2016 The Kubernetes Authors All rights reserved.
     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 "k8s.io/helm/pkg/releaseutil"
    18  
    19  import (
    20  	"reflect"
    21  	"testing"
    22  )
    23  
    24  const manifestFile = `
    25  
    26  ---
    27  apiVersion: v1
    28  kind: Pod
    29  metadata:
    30    name: finding-nemo,
    31    annotations:
    32      "helm.sh/hook": test-success
    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-success
    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(manifestFile)
    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  }