Пример #1
0
func TestListen(t *testing.T) {
	agent := storage.NewAgent()
	app := GetApp("testid", agent)
	dockmsg := messages.DockMessage{"HelloWorld", []string{"JSON"}, false}
	app.Create(dockmsg, testconn{})

	Import := GetImport("testid", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)
	Import.Add()

	if Import.GetId() == "" {
		t.Error("Could not add Import")
	}

	eapp := GetApp("testexp", agent)
	eapp.Create(dockmsg, testconn{})

	export := GetExport("testexp", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)
	export.Add()

	Import.StartListenToFunction("testfun")

	key := export.GetAppKey()
	if key.GetListener("testfun", export)[0].GetId() != Import.GetId() {
		t.Error("failed to listen")
	}
}
Пример #2
0
func TestAppRemoval(t *testing.T) {
	agent := storage.NewAgent()
	app := GetApp("testid", agent)
	dockmsg := messages.DockMessage{"HelloWorld", []string{"JSON"}, false}
	app.Create(dockmsg, testconn{})
	app.Remove()
	if app.Exists() {
		t.Error("Could not remove app")
	}
}
Пример #3
0
func TestImport(t *testing.T) {
	agent := storage.NewAgent()
	app := GetApp("testid", agent)
	dockmsg := messages.DockMessage{"HelloWorld", []string{"JSON"}, false}
	app.Create(dockmsg, testconn{})

	Import := GetImport("", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)
	Import.Add()

	if Import.GetId() != "" {
		t.Error("Created Import for non existing app")
	}
	Import = GetImport("testid", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)
	Import.Add()

	if Import.GetId() == "" {
		t.Error("Could not add Import")
	}
	Import = GetImport("testid", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)

	if Import.GetId() == "" {
		t.Error("Could not retrieve Import")
	}
	key := Import.GetAppKey()
	if !key.Exists() {
		t.Error("Could not create key")
	}

	if len(key.GetImporter()) == 0 {
		t.Error("Could not retrieve import from key")

	}

	if Import.HasExporter() {
		t.Error("Exporter should not be present")
	}
	eapp := GetApp("testexp", agent)
	eapp.Create(dockmsg, testconn{})

	export := GetExport("testexp", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)
	export.Add()
	if !Import.HasExporter() {
		t.Error("Exporter should be present")
	}
	Import.UpdateTags([]string{"hi"})
	if Import.GetTagNames()[0] != "hi" {

		t.Error("Could not retrieve tag from key")

	}

}
Пример #4
0
func TestAppCreation(t *testing.T) {
	agent := storage.NewAgent()
	app := GetApp("testid", agent)
	if app.Exists() {
		t.Error("Found non existing app")
	}
	dockmsg := messages.DockMessage{"HelloWorld", []string{"JSON"}, false}
	if !app.Create(dockmsg, testconn{}) {
		t.Error("Could not create app")
	}
	if !app.Exists() {
		t.Error("Could not find app")
	}
	if app.Create(dockmsg, testconn{}) {
		t.Error("Could create app")
	}
}
Пример #5
0
func TestExport(t *testing.T) {
	agent := storage.NewAgent()
	app := GetApp("testid", agent)
	dockmsg := messages.DockMessage{"HelloWorld", []string{"JSON"}, false}
	app.Create(dockmsg, testconn{})

	export := GetExport("", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)
	export.Add()

	if export.GetId() != "" {
		t.Error("Created export for non existing app")
	}
	export = GetExport("testid", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)
	export.Add()

	if export.GetId() == "" {
		t.Error("Could not add export")
	}
	export = GetExport("testid", keys.HelloAurSirAppKey, []string{"one", "two"}, "", agent)
	export.Add()

	if export.GetId() == "" {
		t.Error("Could not retrieve export")
	}
	if len(export.GetTags()) == 0 {
		t.Error("Could not retrieve tags")

	}
	appkey := export.GetAppKey()
	if len(appkey.GetExporter()) == 0 {
		t.Error("Could not retrieve export from key")

	}

	export.UpdateTags([]string{"hi"})
	if export.GetTagNames()[0] != "hi" {

		t.Error("Could not retrieve tag from key")

	}

}
Пример #6
0
func bootStorage() storage.StorageAgent {
	mprint("Launching Storage")

	return storage.NewAgent()
}
Пример #7
0
func Testprocessor() chan Processor {
	pc := make(chan Processor)
	go Process(pc, storage.NewAgent(), 1)
	return pc
}