github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/engine/docker/container_test.go (about)

     1  package docker
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestRawArgs(t *testing.T) {
    10  	assert := assert.New(t)
    11  
    12  	r1, err := loadRawArgs([]byte(``))
    13  	assert.NoError(err)
    14  	assert.NotEqual(r1.StorageOpt, nil)
    15  	assert.Equal(len(r1.StorageOpt), 0)
    16  	assert.NotEqual(r1.CapAdd, nil)
    17  	assert.Equal(len(r1.CapAdd), 0)
    18  	assert.NotEqual(r1.CapDrop, nil)
    19  	assert.Equal(len(r1.CapDrop), 0)
    20  	assert.NotEqual(r1.Ulimits, nil)
    21  	assert.Equal(len(r1.Ulimits), 0)
    22  
    23  	r2, err := loadRawArgs([]byte(`{"storage_opt": null, "cap_add": null, "cap_drop": null, "ulimits": null}`))
    24  	assert.NoError(err)
    25  	assert.NotEqual(r2.StorageOpt, nil)
    26  	assert.Equal(len(r2.StorageOpt), 0)
    27  	assert.NotEqual(r2.CapAdd, nil)
    28  	assert.Equal(len(r2.CapAdd), 0)
    29  	assert.NotEqual(r2.CapDrop, nil)
    30  	assert.Equal(len(r2.CapDrop), 0)
    31  	assert.NotEqual(r2.Ulimits, nil)
    32  	assert.Equal(len(r2.Ulimits), 0)
    33  
    34  	_, err = loadRawArgs([]byte(`{"storage_opt": null, "cap_add": null, "cap_drop": null, "ulimits"}`))
    35  	assert.Error(err)
    36  }