github.com/hahmadia/mattermost-server@v5.11.1+incompatible/model/bundle_info_test.go (about)

     1  package model
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"path/filepath"
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestBundleInfoForPath(t *testing.T) {
    14  	dir, err := ioutil.TempDir("", "mm-plugin-test")
    15  	require.NoError(t, err)
    16  	defer os.RemoveAll(dir)
    17  
    18  	path := filepath.Join(dir, "plugin.json")
    19  	f, err := os.Create(path)
    20  	require.NoError(t, err)
    21  	_, err = f.WriteString(`{"id": "foo"}`)
    22  	f.Close()
    23  	require.NoError(t, err)
    24  
    25  	info := BundleInfoForPath(dir)
    26  	assert.Equal(t, info.Path, dir)
    27  	assert.NotNil(t, info.Manifest)
    28  	assert.Equal(t, info.ManifestPath, path)
    29  	assert.Nil(t, info.ManifestError)
    30  }