github.com/japiotr123/go-tmux@v0.0.0-20231125144807-6c27c6cf74ba/pane_test.go (about)

     1  // The MIT License (MIT)
     2  // Copyright (C) 2019-2023 Georgiy Komarov <jubnzv@gmail.com>
     3  
     4  package tmux
     5  
     6  import (
     7  	"os"
     8  	"testing"
     9  )
    10  
    11  func TestPaneGetCurrentPath(t *testing.T) {
    12  	if InTravis() {
    13  		t.Skip("Skipping this test in travis.")
    14  	}
    15  
    16  	err := os.Chdir("/tmp")
    17  	if err != nil {
    18  		t.Errorf("There are some problems with /tmp directory: %s", err)
    19  	}
    20  
    21  	s := createSession()
    22  	restoreSession()
    23  	s.AttachSession()
    24  	defer restoreSession()
    25  	defer sessionsReaper(s.Name)
    26  	window, _ := s.NewWindow("test-window")
    27  	panes, _ := window.ListPanes()
    28  	pane := panes[0]
    29  
    30  	path, err := pane.GetCurrentPath()
    31  	if path != "/tmp" {
    32  		t.Errorf("Incorrect path (expected %s got %s)", "/tmp", path)
    33  	}
    34  	if err != nil {
    35  		t.Errorf("%s", err)
    36  	}
    37  }