Skip to content

Commit

Permalink
More code for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
gjhenrique committed Dec 27, 2022
1 parent 85daf49 commit bb36b84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ func Execute() {

func init() {
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.config/yafl/config.toml)")
rootCmd.PersistentFlags().StringVar(&cfgFile, "cacheDir", "", "cache directory (default is $HOME/.cache)")
rootCmd.PersistentFlags().StringVar(&cfgFile, "cache-dir", "", "cache directory (default is $HOME/.cache)")
}
26 changes: 15 additions & 11 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
// "example/cmd"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"

Expand Down Expand Up @@ -35,6 +37,12 @@ func TestFunction(t *testing.T) {
// Set directory
// Set cache dir

tempDir, err := ioutil.TempDir("", "yafl")
defer os.RemoveAll(tempDir)
if err != nil {
t.Fatal(err)
}

name := uniuri.New()
server := new(gotmux.Server)
session, err := server.NewSession(name)
Expand All @@ -43,29 +51,25 @@ func TestFunction(t *testing.T) {
t.Fatal(err)
}

// time.Sleep(5 * time.Second)
panes, err := session.ListPanes()
if len(panes) == 0 || err != nil {
t.Fatal(err)
}

configFile := filepath.Join(tempDir, "config.toml")
cacheDir := filepath.Join(tempDir, "cache")
os.Mkdir(filepath.Join(tempDir, "apps"), 0755)
os.Mkdir(cacheDir, 0755)
exe := fmt.Sprintf("../yafl --config=%s --cache-dir=%s", configFile, tempDir)

s := []string{
"send-keys",
"-t", fmt.Sprintf("%s:0", name),
"../yafl", "Enter",
exe,
}
gotmux.RunCmd(s)

time.Sleep(1 * time.Second)
content, err := panes[0].Capture()
fmt.Println(content)
}

func TestTemp(t *testing.T) {
file, err := ioutil.TempDir("", "yafl")
if err != nil {
t.Fatal(err)
}

fmt.Println(file)
}

0 comments on commit bb36b84

Please sign in to comment.