func TestInstall(t *testing.T) { fetcher := uri.NewLoggedFetcher(nil) testContext := util.From(runtime.Caller(0)) currentUser, err := user.Current() Assert(t).IsNil(err, "test setup: couldn't get current user") testLocation := testContext.ExpandPath("hoisted-hello_3c021aff048ca8117593f9c71e03b87cf72fd440.tar.gz") launchables := map[launch.LaunchableID]launch.LaunchableStanza{ "hello": { LaunchableId: "hello", Location: testLocation, LaunchableType: "hoist", }, } builder := manifest.NewBuilder() builder.SetID("hello") builder.SetLaunchables(launchables) builder.SetRunAsUser(currentUser.Username) manifest := builder.GetManifest() testPodDir, err := ioutil.TempDir("", "testPodDir") Assert(t).IsNil(err, "Got an unexpected error creating a temp directory") defer os.RemoveAll(testPodDir) pod := Pod{ Id: "testPod", home: testPodDir, logger: Log.SubLogger(logrus.Fields{"pod": "testPod"}), Fetcher: fetcher, } err = pod.Install(manifest, auth.NopVerifier(), artifact.NewRegistry(nil, uri.DefaultFetcher, osversion.DefaultDetector)) Assert(t).IsNil(err, "there should not have been an error when installing") Assert(t).AreEqual( fetcher.SrcUri.String(), testLocation, "The correct url wasn't set for the curl library", ) hoistedHelloUnpacked := filepath.Join(testPodDir, "hello", "installs", "hello_3c021aff048ca8117593f9c71e03b87cf72fd440") if info, err := os.Stat(hoistedHelloUnpacked); err != nil || !info.IsDir() { t.Fatalf("Expected %s to be the unpacked artifact location", hoistedHelloUnpacked) } helloLaunch := filepath.Join(hoistedHelloUnpacked, "bin", "launch") if info, err := os.Stat(helloLaunch); err != nil || info.IsDir() { t.Fatalf("Expected %s to be a the launch script for hello", helloLaunch) } }
func TestInstall(t *testing.T) { fetcher := uri.NewLoggedFetcher(nil) testContext := util.From(runtime.Caller(0)) currentUser, err := user.Current() Assert(t).IsNil(err, "test setup: couldn't get current user") testLocation := testContext.ExpandPath("hoisted-hello_def456.tar.gz") launchableHome, err := ioutil.TempDir("", "launchable_home") defer os.RemoveAll(launchableHome) launchable := &Launchable{ Location: testLocation, Id: "hello", RunAs: currentUser.Username, PodEnvDir: launchableHome, Fetcher: fetcher, RootDir: launchableHome, } err = launchable.Install() Assert(t).IsNil(err, "there should not have been an error when installing") Assert(t).AreEqual( fetcher.SrcUri, testLocation, "The correct url wasn't set for the curl library", ) hoistedHelloUnpacked := path.Join(launchableHome, "installs", "hoisted-hello_def456") if info, err := os.Stat(hoistedHelloUnpacked); err != nil || !info.IsDir() { t.Fatalf("Expected %s to be the unpacked artifact location", hoistedHelloUnpacked) } helloLaunch := path.Join(hoistedHelloUnpacked, "bin", "launch") if info, err := os.Stat(helloLaunch); err != nil || info.IsDir() { t.Fatalf("Expected %s to be a the launch script for hello", helloLaunch) } }