Skip to content

Commit

Permalink
test: add TestExecuteWithEnvs
Browse files Browse the repository at this point in the history
Test namespaced execution with environment variables

Longhorn 7672

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit authored and innobead committed Feb 19, 2024
1 parent 91e0f03 commit 081e7dc
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ns/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,28 @@ func (s *TestSuite) TestExecuteWithStdinPipe(c *C) {
c.Assert(output, Equals, "output")
}
}

func (s *TestSuite) TestExecuteWithEnvs(c *C) {
type testCase struct {
timeout time.Duration
}
testCases := map[string]testCase{
"Execute(...)": {
timeout: types.ExecuteNoTimeout,
},
"Execute(...): with namespace": {
timeout: types.ExecuteNoTimeout,
},
}
for testName := range testCases {
c.Logf("testing namespace.%v", testName)

namespaces := []types.Namespace{}
nsexec, err := NewNamespaceExecutor(types.ProcessNone, types.HostProcDirectory, namespaces)
c.Assert(err, IsNil)

output, err := nsexec.Execute([]string{"K1=V1", "K2=V2"}, "env", nil, types.ExecuteDefaultTimeout)
c.Assert(err, IsNil)
c.Assert(output, Equals, "K1=V1\nK2=V2\n")
}
}

0 comments on commit 081e7dc

Please sign in to comment.