github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/updater/command/command_unix_test.go (about)

     1  // Copyright 2016 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  //go:build linux || darwin
     5  // +build linux darwin
     6  
     7  package command
     8  
     9  import (
    10  	"os/exec"
    11  	"testing"
    12  	"time"
    13  
    14  	"github.com/stretchr/testify/assert"
    15  )
    16  
    17  func TestExecWithEnv(t *testing.T) {
    18  	result, err := execWithFunc("printenv", []string{"TESTENV"}, []string{"TESTENV=ok"}, exec.Command, time.Second, testLog)
    19  	assert.NoError(t, err)
    20  	assert.Equal(t, result.Stdout.String(), "ok\n")
    21  }
    22  
    23  func TestExecWithNoEnv(t *testing.T) {
    24  	// Check there is a PATH env var if we pass nil
    25  	result, err := execWithFunc("printenv", []string{"PATH"}, nil, exec.Command, time.Second, testLog)
    26  	assert.NoError(t, err)
    27  	assert.NotEqual(t, result.Stdout.String(), "")
    28  }