github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/worker/runtime/integration/suite_test.go (about)

     1  package integration_test
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os/user"
     6  	"sync"
     7  	"testing"
     8  
     9  	gouuid "github.com/nu7hatch/gouuid"
    10  	"github.com/stretchr/testify/require"
    11  	"github.com/stretchr/testify/suite"
    12  )
    13  
    14  type buffer struct {
    15  	content string
    16  	sync.Mutex
    17  }
    18  
    19  func (m *buffer) Write(p []byte) (n int, err error) {
    20  	m.Lock()
    21  	m.content += string(p)
    22  	m.Unlock()
    23  	return len(p), nil
    24  }
    25  
    26  func (m *buffer) String() string {
    27  	return m.content
    28  }
    29  
    30  func uuid() string {
    31  	u4, err := gouuid.NewV4()
    32  	if err != nil {
    33  		panic("couldn't create new uuid")
    34  	}
    35  
    36  	return u4.String()
    37  }
    38  
    39  func TestSuite(t *testing.T) {
    40  	req := require.New(t)
    41  
    42  	user, err := user.Current()
    43  	req.NoError(err)
    44  
    45  	if user.Uid != "0" {
    46  		t.Skip("must be run as root")
    47  		return
    48  	}
    49  
    50  	tmpDir, err := ioutil.TempDir("", "containerd-test")
    51  	if err != nil {
    52  		panic(err)
    53  	}
    54  	suite.Run(t, &IntegrationSuite{
    55  		Assertions: req,
    56  		tmpDir:     tmpDir,
    57  	})
    58  }