From e8e05452b3b02b79e9bc234240e5fb43753abbfa Mon Sep 17 00:00:00 2001 From: mjcEatYou Date: Mon, 16 Dec 2019 13:36:08 +0800 Subject: [PATCH] test: add paladin config one level symbolic file link (#452) --- pkg/conf/paladin/file_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/conf/paladin/file_test.go b/pkg/conf/paladin/file_test.go index 17ab59fd2..055d8e3e7 100644 --- a/pkg/conf/paladin/file_test.go +++ b/pkg/conf/paladin/file_test.go @@ -116,7 +116,6 @@ func TestHiddenFile(t *testing.T) { number = 100 `), 0644)) // test client - // test client cli, err := NewFile(path) assert.Nil(t, err) assert.NotNil(t, cli) @@ -129,3 +128,19 @@ func TestHiddenFile(t *testing.T) { _, err = cli.Get(".abc.toml").String() assert.NotNil(t, err) } + +func TestOneLevelSymbolicFile(t *testing.T) { + path := "/tmp/test_symbolic_link/" + path2 := "/tmp/test_symbolic_link/configs/" + assert.Nil(t, os.MkdirAll(path2, 0700)) + assert.Nil(t, ioutil.WriteFile(path+"test.toml", []byte(`hello`), 0644)) + assert.Nil(t, os.Symlink(path+"test.toml", path2+"test.toml.ln")) + // test client + cli, err := NewFile(path2) + assert.Nil(t, err) + assert.NotNil(t, cli) + content, _ := cli.Get("test.toml.ln").String() + assert.Equal(t, "hello", content) + os.Remove(path+"test.toml") + os.Remove(path2+"test.toml.ln") +}