Ejemplo n.º 1
0
func TestInstallScriptsFromImage(t *testing.T) {
	defaultURL := "image:///path/in/image"
	defaultResults := map[string]*downloadResult{
		api.Assemble: {defaultURL, errors.NewScriptsInsideImageError(defaultURL)},
		api.Run:      {defaultURL, errors.NewScriptsInsideImageError(defaultURL)},
	}

	testInstall(t, getFakeInstaller(), []string{api.Assemble, api.Run},
		nil, nil, defaultResults, "/working-dir/",
		defaultURL, false, true, nil)
}
Ejemplo n.º 2
0
func TestInstallCombined(t *testing.T) {
	scriptsURL := "http://the.scripts.url"
	userResults := map[string]*downloadResult{
		api.Assemble: {scriptsURL, nil},
	}

	sourceResults := map[string]*downloadResult{
		api.Run: {api.SourceScripts, nil},
	}

	defaultURL := "image:///path/in/image"
	defaultResults := map[string]*downloadResult{
		api.Assemble:      {defaultURL, errors.NewScriptsInsideImageError(defaultURL)},
		api.Run:           {defaultURL, errors.NewScriptsInsideImageError(defaultURL)},
		api.SaveArtifacts: {defaultURL, errors.NewScriptsInsideImageError(defaultURL)},
	}

	inst := getFakeInstaller()
	result := inst.install([]string{api.Assemble, api.Run, api.SaveArtifacts}, userResults, sourceResults, defaultResults, "/working-dir/")

	if len(result) != 3 {
		t.Errorf("Unexpected result length, expected 3, got %d", len(result))
	}
	for _, r := range result {
		if r.Error != nil {
			t.Errorf("Unexpected error during install %s, got %v", r.Script, r.Error)
		}
		switch r.Script {
		case api.Assemble:
			if r.URL != scriptsURL || !r.Downloaded || !r.Installed {
				t.Errorf("Unexpected results for %s: %s, %v, %v", r.Script, r.URL, r.Downloaded, r.Installed)
			}
		case api.Run:
			if r.URL != api.SourceScripts || !r.Downloaded || !r.Installed {
				t.Errorf("Unexpected results for %s: %s, %v, %v", r.Script, r.URL, r.Downloaded, r.Installed)
			}
		case api.SaveArtifacts:
			if r.URL != defaultURL || r.Downloaded || !r.Installed {
				t.Errorf("Unexpected results for %s: %s, %v, %v", r.Script, r.URL, r.Downloaded, r.Installed)
			}
		}
	}
}
Ejemplo n.º 3
0
// Read throws Not implemented error
func (*ImageReader) Read(url *url.URL) (io.ReadCloser, error) {
	return nil, errors.NewScriptsInsideImageError(url.String())
}