aboutsummaryrefslogblamecommitdiffstats
path: root/cmd/utils/customflags_test.go
blob: 11deb38ef243a8c4a51fa7bcb3d03b2918f36826 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


             


                 



                                      
                                 
 





                                                            
 
                                   
 





                                                                                       
 
package utils

import (
    "os"
    "os/user"
    "testing"
)

func TestPathExpansion(t *testing.T) {

    user, _ := user.Current()

    tests := map[string]string{
        "/home/someuser/tmp": "/home/someuser/tmp",
        "~/tmp":              user.HomeDir + "/tmp",
        "$DDDXXX/a/b":        "/tmp/a/b",
        "/a/b/":              "/a/b",
    }

    os.Setenv("DDDXXX", "/tmp")

    for test, expected := range tests {
        got := expandPath(test)
        if got != expected {
            t.Errorf("test %s, got %s, expected %s\n", test, got, expected)
        }
    }
}