github.com/mattermosttest/mattermost-server/v5@v5.0.0-20200917143240-9dfa12e121f9/model/bundle_info_test.go (about)

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