func (s *AptSuite) TestConfigProxyEmpty(c *gc.C) { cmdChan := s.HookCommandOutput(&utils.AptCommandOutput, []byte{}, nil) out, err := utils.AptConfigProxy() c.Assert(err, gc.IsNil) cmd := <-cmdChan c.Assert(cmd.Args, gc.DeepEquals, []string{ "apt-config", "dump", "Acquire::http::Proxy", "Acquire::https::Proxy", "Acquire::ftp::Proxy", }) c.Assert(out, gc.Equals, "") }
func (s *AptSuite) TestConfigProxyConfigured(c *gc.C) { const expected = `Acquire::http::Proxy "10.0.3.1:3142"; Acquire::https::Proxy "false";` cmdChan := s.HookCommandOutput(&utils.AptCommandOutput, []byte(expected), nil) out, err := utils.AptConfigProxy() c.Assert(err, gc.IsNil) cmd := <-cmdChan c.Assert(cmd.Args, gc.DeepEquals, []string{ "apt-config", "dump", "Acquire::http::Proxy", "Acquire::https::Proxy", "Acquire::ftp::Proxy", }) c.Assert(out, gc.Equals, expected) }
func (s *AptSuite) TestConfigProxyError(c *gc.C) { const expected = `E: frobnicator failure detected` cmdError := fmt.Errorf("error") cmdExpectedError := fmt.Errorf("apt-config failed: error") cmdChan := s.HookCommandOutput(&utils.AptCommandOutput, []byte(expected), cmdError) out, err := utils.AptConfigProxy() c.Assert(err, gc.DeepEquals, cmdExpectedError) cmd := <-cmdChan c.Assert(cmd.Args, gc.DeepEquals, []string{ "apt-config", "dump", "Acquire::http::Proxy", "Acquire::https::Proxy", "Acquire::ftp::Proxy", }) c.Assert(out, gc.Equals, "") }