func TestConfig_RecordCommand(t *testing.T) { var tests = []struct { cfg util.ConfigFile env map[string]string expected string }{ { util.ConfigFile{}, map[string]string{}, "/bin/sh", }, { util.ConfigFile{}, map[string]string{"SHELL": "/bin/bash"}, "/bin/bash", }, { util.ConfigFile{Record: util.ConfigRecord{Command: "foo -l"}}, map[string]string{"SHELL": "/bin/bash"}, "foo -l", }, } for _, test := range tests { cfg := util.Config{&test.cfg, test.env} actual := cfg.RecordCommand() if actual != test.expected { t.Errorf(`expected "%v", got "%v"`, test.expected, actual) } } }