asdf/internal/info/info_test.go
Trevor Brown 447acd13d1 feat(golang-rewrite): info command
* Implement info command
* Remove duplicate and unneeded BATS tests from `main_test.go`
* remove download dir for plugin when removing plugin
* update plugins.Add function so downloads directory is created
2024-12-18 11:32:01 -05:00

34 lines
828 B
Go

package info
import (
"os"
"path/filepath"
"strings"
"testing"
"asdf/config"
"github.com/stretchr/testify/assert"
)
func TestWrite(t *testing.T) {
testDataDir := t.TempDir()
err := os.MkdirAll(filepath.Join(testDataDir, "plugins"), 0o777)
assert.Nil(t, err)
conf := config.Config{DataDir: testDataDir}
var stdout strings.Builder
err = Write(conf, "0.15.0", &stdout)
assert.Nil(t, err)
output := stdout.String()
// Simple format assertions
assert.True(t, strings.Contains(output, "OS:\n"))
assert.True(t, strings.Contains(output, "BASH VERSION:\n"))
assert.True(t, strings.Contains(output, "SHELL:\n"))
assert.True(t, strings.Contains(output, "ASDF VERSION:\n"))
assert.True(t, strings.Contains(output, "INTERNAL VARIABLES:\n"))
assert.True(t, strings.Contains(output, "ASDF INSTALLED PLUGINS:\n"))
}