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

     1  // © Broadcom. All Rights Reserved.
     2  // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package ovf
     6  
     7  import "testing"
     8  
     9  func testEnv() Env {
    10  	return Env{
    11  		EsxID: "vm moref",
    12  		Platform: &PlatformSection{
    13  			Kind:    "VMware vCenter Server",
    14  			Version: "5.5.0",
    15  			Vendor:  "VMware, Inc.",
    16  			Locale:  "US",
    17  		},
    18  		Property: &PropertySection{
    19  			Properties: []EnvProperty{
    20  				{"foo", "bar"},
    21  				{"ham", "eggs"}}},
    22  	}
    23  }
    24  
    25  func TestMarshalEnv(t *testing.T) {
    26  	env := testEnv()
    27  
    28  	xenv, err := env.Marshal()
    29  	if err != nil {
    30  		t.Fatalf("error marshalling environment %s", err)
    31  	}
    32  	if len(xenv) < 1 {
    33  		t.Fatal("marshalled document is empty")
    34  	}
    35  }
    36  
    37  func TestMarshalManualEnv(t *testing.T) {
    38  	env := testEnv()
    39  
    40  	xenv := env.MarshalManual()
    41  	if len(xenv) < 1 {
    42  		t.Fatal("marshal document is empty")
    43  	}
    44  }