github.com/tiagovtristao/plz@v13.4.0+incompatible/src/test/container_test.go (about)

     1  package test
     2  
     3  import "io/ioutil"
     4  import "os"
     5  import "path/filepath"
     6  import "testing"
     7  
     8  func TestInContainer(t *testing.T) {
     9  	abs, err := filepath.Abs(os.Args[0])
    10  	if err != nil {
    11  		t.Errorf("Couldn't make path absolute: %s", err)
    12  	} else if abs != "/tmp/test/container_test" {
    13  		t.Errorf("Looks like we're not running inside a container: %s", os.Args[0])
    14  	}
    15  }
    16  
    17  func TestContainerData(t *testing.T) {
    18  	data, err := ioutil.ReadFile("src/test/test_data/container_data.txt")
    19  	if err != nil {
    20  		t.Errorf("Failed to read data file: %s", err)
    21  	} else {
    22  		expected := "This file will only appear in the container if data is working properly.\n"
    23  		if string(data) != expected {
    24  			t.Errorf("Unexpected file contents: expected [%s], was [%s]", expected, string(data))
    25  		}
    26  	}
    27  }