github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/exp/pox/pox_test.go (about)

     1  // Copyright 2017-2018 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"strings"
     9  	"testing"
    10  )
    11  
    12  func TestExtraMounts(t *testing.T) {
    13  	for _, tt := range []struct {
    14  		name    string
    15  		extra   string
    16  		wantErr string
    17  	}{
    18  		{
    19  			name: "mountList == ''",
    20  		},
    21  		{
    22  			name:    "len(bin) == 0",
    23  			extra:   "::",
    24  			wantErr: "[\"\" \"\" \"\"] is not in the form src:target",
    25  		},
    26  		{
    27  			name:  "switch case 1",
    28  			extra: "/tmp, /etc"},
    29  		{
    30  			name:  "switch case 2",
    31  			extra: "/tmp:/tmp,/etc:/etc",
    32  		},
    33  	} {
    34  		t.Run(tt.name, func(t *testing.T) {
    35  			*extra = tt.extra
    36  			if got := extraMounts(tt.extra); got != nil {
    37  				if !strings.Contains(got.Error(), tt.wantErr) {
    38  					t.Errorf("extraMounts() = %q, want: %q", got.Error(), tt.wantErr)
    39  				}
    40  			}
    41  		})
    42  	}
    43  }