...

Source file src/github.com/Microsoft/hcsshim/internal/oci/util_test.go

Documentation: github.com/Microsoft/hcsshim/internal/oci

     1  package oci
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/opencontainers/runtime-spec/specs-go"
     7  )
     8  
     9  func Test_IsLCOW_WCOW(t *testing.T) {
    10  	s := &specs.Spec{
    11  		Windows: &specs.Windows{},
    12  	}
    13  	if IsLCOW(s) {
    14  		t.Fatal("should not have returned LCOW spec for WCOW config")
    15  	}
    16  }
    17  
    18  func Test_IsLCOW_WCOW_Isolated(t *testing.T) {
    19  	s := &specs.Spec{
    20  		Windows: &specs.Windows{
    21  			HyperV: &specs.WindowsHyperV{},
    22  		},
    23  	}
    24  	if IsLCOW(s) {
    25  		t.Fatal("should not have returned LCOW spec for WCOW isolated config")
    26  	}
    27  }
    28  
    29  func Test_IsLCOW_Success(t *testing.T) {
    30  	s := &specs.Spec{
    31  		Linux: &specs.Linux{},
    32  		Windows: &specs.Windows{
    33  			HyperV: &specs.WindowsHyperV{},
    34  		},
    35  	}
    36  	if !IsLCOW(s) {
    37  		t.Fatal("should have returned LCOW spec")
    38  	}
    39  }
    40  
    41  func Test_IsLCOW_NoWindows_Success(t *testing.T) {
    42  	s := &specs.Spec{
    43  		Linux: &specs.Linux{},
    44  	}
    45  	if !IsLCOW(s) {
    46  		t.Fatal("should have returned LCOW spec")
    47  	}
    48  }
    49  
    50  func Test_IsLCOW_Neither(t *testing.T) {
    51  	s := &specs.Spec{}
    52  
    53  	if IsLCOW(s) {
    54  		t.Fatal("should not have returned LCOW spec for neither config")
    55  	}
    56  }
    57  
    58  func Test_IsWCOW_Success(t *testing.T) {
    59  	s := &specs.Spec{
    60  		Windows: &specs.Windows{},
    61  	}
    62  	if !IsWCOW(s) {
    63  		t.Fatal("should have returned WCOW spec for WCOW config")
    64  	}
    65  }
    66  
    67  func Test_IsWCOW_Isolated_Success(t *testing.T) {
    68  	s := &specs.Spec{
    69  		Windows: &specs.Windows{
    70  			HyperV: &specs.WindowsHyperV{},
    71  		},
    72  	}
    73  	if !IsWCOW(s) {
    74  		t.Fatal("should have returned WCOW spec for WCOW isolated config")
    75  	}
    76  }
    77  
    78  func Test_IsWCOW_LCOW(t *testing.T) {
    79  	s := &specs.Spec{
    80  		Linux: &specs.Linux{},
    81  		Windows: &specs.Windows{
    82  			HyperV: &specs.WindowsHyperV{},
    83  		},
    84  	}
    85  	if IsWCOW(s) {
    86  		t.Fatal("should not have returned WCOW spec for LCOW config")
    87  	}
    88  }
    89  
    90  func Test_IsWCOW_LCOW_NoWindows_Success(t *testing.T) {
    91  	s := &specs.Spec{
    92  		Linux: &specs.Linux{},
    93  	}
    94  	if IsWCOW(s) {
    95  		t.Fatal("should not have returned WCOW spec for LCOW config")
    96  	}
    97  }
    98  
    99  func Test_IsWCOW_Neither(t *testing.T) {
   100  	s := &specs.Spec{}
   101  
   102  	if IsWCOW(s) {
   103  		t.Fatal("should not have returned WCOW spec for neither config")
   104  	}
   105  }
   106  
   107  func Test_IsIsolated_WCOW(t *testing.T) {
   108  	s := &specs.Spec{
   109  		Windows: &specs.Windows{},
   110  	}
   111  	if IsIsolated(s) {
   112  		t.Fatal("should not have returned isolated for WCOW config")
   113  	}
   114  }
   115  
   116  func Test_IsIsolated_WCOW_Isolated(t *testing.T) {
   117  	s := &specs.Spec{
   118  		Windows: &specs.Windows{
   119  			HyperV: &specs.WindowsHyperV{},
   120  		},
   121  	}
   122  	if !IsIsolated(s) {
   123  		t.Fatal("should have returned isolated for WCOW isolated config")
   124  	}
   125  }
   126  
   127  func Test_IsIsolated_LCOW(t *testing.T) {
   128  	s := &specs.Spec{
   129  		Linux: &specs.Linux{},
   130  		Windows: &specs.Windows{
   131  			HyperV: &specs.WindowsHyperV{},
   132  		},
   133  	}
   134  	if !IsIsolated(s) {
   135  		t.Fatal("should have returned isolated for LCOW config")
   136  	}
   137  }
   138  
   139  func Test_IsIsolated_LCOW_NoWindows(t *testing.T) {
   140  	s := &specs.Spec{
   141  		Linux: &specs.Linux{},
   142  	}
   143  	if !IsIsolated(s) {
   144  		t.Fatal("should have returned isolated for LCOW config")
   145  	}
   146  }
   147  
   148  func Test_IsIsolated_Neither(t *testing.T) {
   149  	s := &specs.Spec{}
   150  
   151  	if IsIsolated(s) {
   152  		t.Fatal("should have not have returned isolated for neither config")
   153  	}
   154  }
   155  

View as plain text