github.com/jonsyu1/godel@v0.0.0-20171017211503-64567a0cf169/pkg/products/products_test.go (about)

     1  // Copyright 2016 Palantir Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package products_test
    16  
    17  import (
    18  	"os/exec"
    19  	"strings"
    20  	"testing"
    21  
    22  	"github.com/stretchr/testify/assert"
    23  	"github.com/stretchr/testify/require"
    24  
    25  	"github.com/palantir/godel/pkg/products"
    26  )
    27  
    28  func TestList(t *testing.T) {
    29  	p, err := products.List()
    30  	require.NoError(t, err)
    31  	assert.Equal(t, []string{"distgo", "godel", "gonform", "gunit", "okgo"}, p)
    32  }
    33  
    34  func TestBin(t *testing.T) {
    35  	bin, err := products.Bin("godel")
    36  	require.NoError(t, err)
    37  	cmd := exec.Command(bin, "version")
    38  	output, err := cmd.CombinedOutput()
    39  	require.NoError(t, err)
    40  
    41  	assert.True(t, strings.HasPrefix(string(output), "godel version"))
    42  }
    43  
    44  func TestDist(t *testing.T) {
    45  	dist, err := products.Dist("godel")
    46  	require.NoError(t, err)
    47  	assert.True(t, strings.HasSuffix(dist, ".tgz"))
    48  }