47 lines
964 B
Go
47 lines
964 B
Go
package core_test
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git.hrafn.xyz/aether/gosick/internal/homesick/core"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type VersionSuite struct {
|
|
suite.Suite
|
|
tmpDir string
|
|
homeDir string
|
|
reposDir string
|
|
stdout *bytes.Buffer
|
|
app *core.App
|
|
}
|
|
|
|
func TestVersionSuite(t *testing.T) {
|
|
suite.Run(t, new(VersionSuite))
|
|
}
|
|
|
|
func (s *VersionSuite) SetupTest() {
|
|
s.tmpDir = s.T().TempDir()
|
|
s.homeDir = filepath.Join(s.tmpDir, "home")
|
|
s.reposDir = filepath.Join(s.homeDir, ".homesick", "repos")
|
|
require.NoError(s.T(), os.MkdirAll(s.reposDir, 0o755))
|
|
|
|
s.stdout = &bytes.Buffer{}
|
|
s.app = &core.App{
|
|
HomeDir: s.homeDir,
|
|
ReposDir: s.reposDir,
|
|
Stdout: s.stdout,
|
|
Stderr: io.Discard,
|
|
}
|
|
}
|
|
|
|
func (s *VersionSuite) TestVersion_WritesVersionToAppStdout() {
|
|
require.NoError(s.T(), s.app.Version("1.2.3"))
|
|
require.Equal(s.T(), "1.2.3\n", s.stdout.String())
|
|
}
|