github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/core/network/package_test.go (about) 1 // Copyright 2019 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package network 5 6 import ( 7 "testing" 8 9 jujutesting "github.com/juju/testing" 10 gc "gopkg.in/check.v1" 11 ) 12 13 //go:generate go run go.uber.org/mock/mockgen -package network_test -destination discovery_mock_test.go github.com/juju/juju/core/network ConfigSource,ConfigSourceNIC,ConfigSourceAddr 14 15 func TestPackage(t *testing.T) { 16 gc.TestingT(t) 17 } 18 19 // BaseSuite exposes base testing functionality to the network tests, 20 // including patching package-private functions/variables. 21 type BaseSuite struct { 22 jujutesting.IsolationSuite 23 } 24 25 // PatchGOOS allows us to simulate the running OS. 26 func (s *BaseSuite) PatchGOOS(os string) { 27 s.PatchValue(&goos, func() string { return os }) 28 } 29 30 // PatchUnIPRouteShow allows us to simulate the return from running 31 // "ip route show" on the host. 32 func (s *BaseSuite) PatchRunIPRouteShow(run func() (string, error)) { 33 s.PatchValue(&runIPRouteShow, run) 34 }