github.com/vmware/govmomi@v0.37.2/ovf/env_test.go (about)

     1  /*
     2  Copyright (c) 2015-2023 VMware, Inc. 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  package ovf
    17  
    18  import "testing"
    19  
    20  func testEnv() Env {
    21  	return Env{
    22  		EsxID: "vm moref",
    23  		Platform: &PlatformSection{
    24  			Kind:    "VMware vCenter Server",
    25  			Version: "5.5.0",
    26  			Vendor:  "VMware, Inc.",
    27  			Locale:  "US",
    28  		},
    29  		Property: &PropertySection{
    30  			Properties: []EnvProperty{
    31  				{"foo", "bar"},
    32  				{"ham", "eggs"}}},
    33  	}
    34  }
    35  
    36  func TestMarshalEnv(t *testing.T) {
    37  	env := testEnv()
    38  
    39  	xenv, err := env.Marshal()
    40  	if err != nil {
    41  		t.Fatalf("error marshalling environment %s", err)
    42  	}
    43  	if len(xenv) < 1 {
    44  		t.Fatal("marshalled document is empty")
    45  	}
    46  }
    47  
    48  func TestMarshalManualEnv(t *testing.T) {
    49  	env := testEnv()
    50  
    51  	xenv := env.MarshalManual()
    52  	if len(xenv) < 1 {
    53  		t.Fatal("marshal document is empty")
    54  	}
    55  }