コード例 #1
1
func (test *TestIterationRepository) TestListIterationBySpace() {
	t := test.T()
	resource.Require(t, resource.Database)

	repo := iteration.NewIterationRepository(test.DB)

	spaceID := uuid.NewV4()

	for i := 0; i < 3; i++ {
		start := time.Now()
		end := start.Add(time.Hour * (24 * 8 * 3))
		name := "Sprint #2" + strconv.Itoa(i)

		i := iteration.Iteration{
			Name:    name,
			SpaceID: spaceID,
			StartAt: &start,
			EndAt:   &end,
		}
		repo.Create(context.Background(), &i)
	}
	repo.Create(context.Background(), &iteration.Iteration{
		Name:    "Other Spring #2",
		SpaceID: uuid.NewV4(),
	})

	its, err := repo.List(context.Background(), spaceID)
	assert.Nil(t, err)
	assert.Len(t, its, 3)
}
コード例 #2
0
func TestConvertStringToKind(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)

	_, err := convertStringToKind("DefinitivelyNotAKind")
	assert.NotNil(t, err)
}
コード例 #3
0
func (test *TestIterationRepository) TestCreateIteration() {
	t := test.T()
	resource.Require(t, resource.Database)

	repo := iteration.NewIterationRepository(test.DB)

	start := time.Now()
	end := start.Add(time.Hour * (24 * 8 * 3))
	name := "Sprint #24"

	i := iteration.Iteration{
		Name:    name,
		SpaceID: uuid.NewV4(),
		StartAt: &start,
		EndAt:   &end,
	}

	repo.Create(context.Background(), &i)
	if i.ID == uuid.Nil {
		t.Errorf("Iteration was not created, ID nil")
	}

	if i.CreatedAt.After(time.Now()) {
		t.Errorf("Iteration was not created, CreatedAt after Now()?")
	}
	assert.Equal(t, start, *i.StartAt)
	assert.Equal(t, end, *i.EndAt)
	assert.Equal(t, name, i.Name)
}
コード例 #4
0
ファイル: comment_test.go プロジェクト: Ritsyy/almighty-core
func (test *TestCommentRepository) TestDeleteComment() {
	t := test.T()
	resource.Require(t, resource.Database)

	defer cleaner.DeleteCreatedEntities(test.DB)()

	repo := comment.NewCommentRepository(test.DB)

	parentID := "AA"
	c := &comment.Comment{
		ParentID:  parentID,
		Body:      "Test AA",
		CreatedBy: uuid.NewV4(),
		ID:        uuid.NewV4(),
	}

	repo.Create(context.Background(), c)
	if c.ID == uuid.Nil {
		t.Errorf("Comment was not created, ID nil")
	}

	c.Body = "Test AB"
	err := repo.Delete(context.Background(), c.ID)

	if err != nil {
		t.Error("Failed to Delete", err.Error())
	}

}
コード例 #5
0
func TestSearch(t *testing.T) {
	resource.Require(t, resource.Database)
	defer cleaner.DeleteCreatedEntities(DB)()

	service := getServiceAsUser()
	wiRepo := workitem.NewWorkItemRepository(DB)

	_, err := wiRepo.Create(
		context.Background(),
		workitem.SystemBug,
		map[string]interface{}{
			workitem.SystemTitle:       "specialwordforsearch",
			workitem.SystemDescription: nil,
			workitem.SystemCreator:     "baijum",
			workitem.SystemState:       workitem.SystemStateClosed,
		},
		"")
	require.Nil(t, err)
	controller := NewSearchController(service, gormapplication.NewGormDB(DB))
	q := "specialwordforsearch"
	_, sr := test.ShowSearchOK(t, nil, nil, controller, nil, nil, q)
	require.NotEmpty(t, sr.Data)
	r := sr.Data[0]
	assert.Equal(t, "specialwordforsearch", r.Attributes[workitem.SystemTitle])
}
コード例 #6
0
func TestUnregisteredURLWithPort(t *testing.T) {
	resource.Require(t, resource.Database)
	defer cleaner.DeleteCreatedEntities(DB)()
	service := getServiceAsUser()
	wiRepo := workitem.NewWorkItemRepository(DB)

	description := "Related to http://some-other-domain:8080/different-path/154687364529310/ok issue"
	expectedDescription := rendering.NewMarkupContentFromLegacy(description)
	_, err := wiRepo.Create(
		context.Background(),
		workitem.SystemBug,
		map[string]interface{}{
			workitem.SystemTitle:       "specialwordforsearch_new",
			workitem.SystemDescription: expectedDescription,
			workitem.SystemCreator:     "baijum",
			workitem.SystemState:       workitem.SystemStateClosed,
		},
		"")
	require.Nil(t, err)

	controller := NewSearchController(service, gormapplication.NewGormDB(DB))
	q := `http://some-other-domain:8080/different-path/`
	_, sr := test.ShowSearchOK(t, nil, nil, controller, nil, nil, q)
	require.NotEmpty(t, sr.Data)
	r := sr.Data[0]
	assert.Equal(t, description, r.Attributes[workitem.SystemDescription])
}
コード例 #7
0
func (rest *TestSpaceIterationREST) TestSuccessCreateIterationWithOptionalValues() {
	t := rest.T()
	resource.Require(t, resource.Database)

	var p *space.Space
	iterationName := "Sprint #22"
	iterationDesc := "testing description"
	ci := createSpaceIteration(iterationName, &iterationDesc)

	application.Transactional(rest.db, func(app application.Application) error {
		repo := app.Spaces()
		testSpace := space.Space{
			Name: "Test 1",
		}
		p, _ = repo.Create(context.Background(), &testSpace)
		return nil
	})
	svc, ctrl := rest.SecuredController()
	_, c := test.CreateSpaceIterationsCreated(t, svc.Context, svc, ctrl, p.ID.String(), ci)
	assert.NotNil(t, c.Data.ID)
	assert.NotNil(t, c.Data.Relationships.Space)
	assert.Equal(t, p.ID.String(), *c.Data.Relationships.Space.Data.ID)
	assert.Equal(t, *c.Data.Attributes.Name, iterationName)
	assert.Equal(t, *c.Data.Attributes.Description, iterationDesc)

	// create another Iteration with nil description
	iterationName2 := "Sprint #23"
	ci = createSpaceIteration(iterationName2, nil)
	_, c = test.CreateSpaceIterationsCreated(t, svc.Context, svc, ctrl, p.ID.String(), ci)
	assert.Equal(t, *c.Data.Attributes.Name, iterationName2)
	assert.Nil(t, c.Data.Attributes.Description)
}
コード例 #8
0
func TestGetTrackerQuery(t *testing.T) {
	resource.Require(t, resource.Database)
	defer cleaner.DeleteCreatedEntities(DB)()
	controller := TrackerController{Controller: nil, db: gormapplication.NewGormDB(DB), scheduler: RwiScheduler}
	payload := app.CreateTrackerAlternatePayload{
		URL:  "http://api.github.com",
		Type: "github",
	}
	_, result := test.CreateTrackerCreated(t, nil, nil, &controller, &payload)

	tqController := TrackerqueryController{Controller: nil, db: gormapplication.NewGormDB(DB), scheduler: RwiScheduler}
	tqpayload := app.CreateTrackerQueryAlternatePayload{

		Query:     "is:open is:issue user:arquillian author:aslakknutsen",
		Schedule:  "15 * * * * *",
		TrackerID: result.ID,
	}
	fmt.Printf("tq payload %#v", tqpayload)
	_, tqresult := test.CreateTrackerqueryCreated(t, nil, nil, &tqController, &tqpayload)
	test.ShowTrackerqueryOK(t, nil, nil, &tqController, tqresult.ID)
	_, tqr := test.ShowTrackerqueryOK(t, nil, nil, &tqController, tqresult.ID)

	if tqr == nil {
		t.Fatalf("Tracker Query '%s' not present", tqresult.ID)
	}
	if tqr.ID != tqresult.ID {
		t.Errorf("Id should be %s, but is %s", tqresult.ID, tqr.ID)
	}
}
コード例 #9
0
ファイル: tracker_test.go プロジェクト: Ritsyy/almighty-core
func TestGetTracker(t *testing.T) {
	resource.Require(t, resource.Database)
	defer cleaner.DeleteCreatedEntities(DB)()
	controller := TrackerController{Controller: nil, db: gormapplication.NewGormDB(DB), scheduler: RwiScheduler}
	payload := app.CreateTrackerAlternatePayload{
		URL:  "http://issues.jboss.com",
		Type: "jira",
	}

	_, result := test.CreateTrackerCreated(t, nil, nil, &controller, &payload)
	test.ShowTrackerOK(t, nil, nil, &controller, result.ID)
	_, tr := test.ShowTrackerOK(t, nil, nil, &controller, result.ID)
	if tr == nil {
		t.Fatalf("Tracker '%s' not present", result.ID)
	}
	if tr.ID != result.ID {
		t.Errorf("Id should be %s, but is %s", result.ID, tr.ID)
	}

	payload2 := app.UpdateTrackerAlternatePayload{
		URL:  tr.URL,
		Type: tr.Type,
	}
	_, updated := test.UpdateTrackerOK(t, nil, nil, &controller, tr.ID, &payload2)
	if updated.ID != result.ID {
		t.Errorf("Id has changed from %s to %s", result.ID, updated.ID)
	}
	if updated.URL != result.URL {
		t.Errorf("URL has changed from %s to %s", result.URL, updated.URL)
	}
	if updated.Type != result.Type {
		t.Errorf("Type has changed has from %s to %s", result.Type, updated.Type)
	}

}
コード例 #10
0
func TestListType_Equal(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)

	a := ListType{
		SimpleType:    SimpleType{Kind: KindList},
		ComponentType: SimpleType{Kind: KindString},
	}

	// Test type incompatibility
	assert.False(t, a.Equal(convert.DummyEqualer{}))

	// Test simple type difference
	b := ListType{
		SimpleType:    SimpleType{Kind: KindString},
		ComponentType: SimpleType{Kind: KindString},
	}
	assert.False(t, a.Equal(b))

	// Test component type difference
	c := ListType{
		SimpleType:    SimpleType{Kind: KindList},
		ComponentType: SimpleType{Kind: KindInteger},
	}
	assert.False(t, a.Equal(c))

	// Test equality
	d := ListType{
		SimpleType:    SimpleType{Kind: KindList},
		ComponentType: SimpleType{Kind: KindString},
	}
	assert.True(t, d.Equal(a))
	assert.True(t, a.Equal(d)) // test the inverse
}
コード例 #11
0
ファイル: area_test.go プロジェクト: Ritsyy/almighty-core
func (test *TestAreaRepository) TestCreateChildArea() {
	t := test.T()

	resource.Require(t, resource.Database)

	repo := area.NewAreaRepository(test.DB)

	name := "Area #24"
	name2 := "Area #24.1"

	i := area.Area{
		Name:    name,
		SpaceID: uuid.NewV4(),
	}
	err := repo.Create(context.Background(), &i)
	assert.Nil(t, err)

	// ltree field doesnt accept "-" , so we will save them as "_"
	expectedPath := strings.Replace((i.ID).String(), "-", "_", -1)
	area2 := area.Area{
		Name:    name2,
		SpaceID: uuid.NewV4(),
		Path:    expectedPath,
	}
	err = repo.Create(context.Background(), &area2)
	assert.Nil(t, err)

	actualArea, err := repo.Load(context.Background(), area2.ID)
	actualPath := actualArea.Path
	require.Nil(t, err)
	require.NotNil(t, actualArea)
	assert.Equal(t, expectedPath, actualPath)

}
コード例 #12
0
ファイル: area_test.go プロジェクト: Ritsyy/almighty-core
func (test *TestAreaRepository) TestCreateArea() {
	t := test.T()

	resource.Require(t, resource.Database)

	repo := area.NewAreaRepository(test.DB)

	name := "Area 21"

	i := area.Area{
		Name:    name,
		SpaceID: uuid.NewV4(),
	}

	repo.Create(context.Background(), &i)
	if i.ID == uuid.Nil {
		t.Errorf("Area was not created, ID nil")
	}

	if i.CreatedAt.After(time.Now()) {
		t.Errorf("Area was not created, CreatedAt after Now()?")
	}

	assert.Equal(t, name, i.Name)
}
コード例 #13
0
func TestFlattenMap(t *testing.T) {
	resource.Require(t, resource.UnitTest)
	testString := []byte(`{"admins":[{"name":"aslak"}],"name":"shoubhik", "assignee":{"fixes": 2, "complete" : true,"foo":[ 1,2,3,4],"1":"sbose","2":"pranav","participants":{"4":"sbose56","5":"sbose78"}},"name":"shoubhik"}`)
	var nestedMap map[string]interface{}
	err := json.Unmarshal(testString, &nestedMap)

	if err != nil {
		t.Error("Incorrect dataset ", testString)
	}
	OneLevelMap := make(map[string]interface{})

	flatten(OneLevelMap, nestedMap, nil)

	// Test for string
	assert.Equal(t, OneLevelMap["assignee.participants.4"], "sbose56", "Incorrect mapping found for assignee.participants.4")

	// test for int
	assert.Equal(t, int(OneLevelMap["assignee.fixes"].(float64)), 2)

	// test for array
	assert.Equal(t, OneLevelMap["assignee.foo.0"], float64(1))

	// test for boolean
	assert.Equal(t, OneLevelMap["assignee.complete"], true)

	// test for array of object(s)
	assert.Equal(t, OneLevelMap["admins.0.name"], "aslak")
}
コード例 #14
0
func TestEnumType_Equal(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)

	stEnum := workitem.SimpleType{Kind: workitem.KindEnum}
	a := workitem.EnumType{
		BaseType: stEnum,
		Values:   []interface{}{"foo", "bar"},
	}

	// Test type inequality
	assert.False(t, a.Equal(convert.DummyEqualer{}))

	// Test simple type difference
	stInteger := workitem.SimpleType{Kind: workitem.KindInteger}
	b := workitem.EnumType{
		SimpleType: workitem.SimpleType{Kind: workitem.KindInteger},
		BaseType:   stInteger,
	}
	assert.False(t, a.Equal(b))

	// Test base type difference
	c := workitem.EnumType{
		BaseType: stInteger,
	}
	assert.False(t, a.Equal(c))

	// Test values difference
	d := workitem.EnumType{
		BaseType: stEnum,
		Values:   []interface{}{"foo1", "bar2"},
	}
	assert.False(t, a.Equal(d))
}
コード例 #15
0
func TestConvertAnyToKind(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)

	_, err := convertAnyToKind(1234)
	assert.NotNil(t, err)
}
コード例 #16
0
func TestConcurrentMigrations(t *testing.T) {
	resource.Require(t, resource.Database)

	var err error
	if err = configuration.Setup(""); err != nil {
		panic(fmt.Errorf("Failed to setup the configuration: %s", err.Error()))
	}

	var wg sync.WaitGroup

	for i := 0; i < 20; i++ {
		wg.Add(1)

		go func() {
			defer wg.Done()
			db, err := sql.Open("postgres", configuration.GetPostgresConfigString())
			if err != nil {
				t.Fatalf("Cannot connect to DB: %s\n", err)
			}
			err = Migrate(db)
			assert.Nil(t, err)
		}()

	}
	wg.Wait()
}
コード例 #17
0
// This test ensures that List does not return NIL items.
func TestTrackerQueryListItemsNotNil(t *testing.T) {
	resource.Require(t, resource.Database)
	defer cleaner.DeleteCreatedEntities(DB)()
	controller := TrackerController{Controller: nil, db: gormapplication.NewGormDB(DB), scheduler: RwiScheduler}
	payload := app.CreateTrackerAlternatePayload{
		URL:  "http://api.github.com",
		Type: "github",
	}
	_, result := test.CreateTrackerCreated(t, nil, nil, &controller, &payload)
	t.Log(result.ID)
	tqController := TrackerqueryController{Controller: nil, db: gormapplication.NewGormDB(DB), scheduler: RwiScheduler}
	tqpayload := app.CreateTrackerQueryAlternatePayload{

		Query:     "is:open is:issue user:arquillian author:aslakknutsen",
		Schedule:  "15 * * * * *",
		TrackerID: result.ID,
	}
	test.CreateTrackerqueryCreated(t, nil, nil, &tqController, &tqpayload)
	test.CreateTrackerqueryCreated(t, nil, nil, &tqController, &tqpayload)

	_, list := test.ListTrackerqueryOK(t, nil, nil, &tqController)
	for _, tq := range list {
		if tq == nil {
			t.Error("Returned Tracker Query found nil")
		}
	}
}
コード例 #18
0
func TestNewWorkitemController(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)
	assert.Panics(t, func() {
		NewWorkitemController(goa.New("Test service"), nil)
	})
}
コード例 #19
0
func (rest *TestSpaceIterationREST) TestFailListIterationsByMissingSpace() {
	t := rest.T()
	resource.Require(t, resource.Database)

	svc, ctrl := rest.UnSecuredController()
	test.ListSpaceIterationsNotFound(t, svc.Context, svc, ctrl, uuid.NewV4().String())
}
コード例 #20
0
func TestParseLimit(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)

	// Test parsing error in parseInts
	str := "1000, foo"
	integers, length, err := parseLimit(&str)
	assert.NotNil(t, err)
	assert.Equal(t, 0, length)
	assert.Nil(t, integers)

	// Test length = 1
	str = "1000"
	integers, length, err = parseLimit(&str)
	assert.Nil(t, err)
	assert.Equal(t, 1000, length)
	assert.Nil(t, integers)

	// Test empty string
	str = ""
	integers, length, err = parseLimit(&str)
	assert.Nil(t, err)
	assert.Equal(t, 100, length)
	assert.Nil(t, integers)
}
コード例 #21
0
func TestSearchURLWithoutPort(t *testing.T) {
	resource.Require(t, resource.Database)
	defer cleaner.DeleteCreatedEntities(DB)()
	service := getServiceAsUser()
	wiRepo := workitem.NewWorkItemRepository(DB)

	description := "This issue is related to http://localhost/detail/876394"
	expectedDescription := rendering.NewMarkupContentFromLegacy(description)
	_, err := wiRepo.Create(
		context.Background(),
		workitem.SystemBug,
		map[string]interface{}{
			workitem.SystemTitle:       "specialwordforsearch_without_port",
			workitem.SystemDescription: expectedDescription,
			workitem.SystemCreator:     "baijum",
			workitem.SystemState:       workitem.SystemStateClosed,
		},
		"")
	require.Nil(t, err)

	controller := NewSearchController(service, gormapplication.NewGormDB(DB))
	q := `"http://localhost/detail/876394"`
	_, sr := test.ShowSearchOK(t, nil, nil, controller, nil, nil, q)
	require.NotEmpty(t, sr.Data)
	r := sr.Data[0]
	assert.Equal(t, description, r.Attributes[workitem.SystemDescription])
}
コード例 #22
0
func TestWorkItemLinkCategory_ConvertLinkCategoryFromModel(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)

	description := "An example description"
	m := link.WorkItemLinkCategory{
		ID:          satoriuuid.FromStringOrNil("0e671e36-871b-43a6-9166-0c4bd573e231"),
		Name:        "Example work item link category",
		Description: &description,
		Version:     0,
	}

	id := m.ID.String()
	expected := app.WorkItemLinkCategorySingle{
		Data: &app.WorkItemLinkCategoryData{
			Type: link.EndpointWorkItemLinkCategories,
			ID:   &id,
			Attributes: &app.WorkItemLinkCategoryAttributes{
				Name:        &m.Name,
				Description: m.Description,
				Version:     &m.Version,
			},
		},
	}

	actual := link.ConvertLinkCategoryFromModel(m)
	require.Equal(t, expected.Data.Type, actual.Data.Type)
	require.Equal(t, *expected.Data.ID, *actual.Data.ID)
	require.Equal(t, *expected.Data.Attributes.Name, *actual.Data.Attributes.Name)
	require.Equal(t, *expected.Data.Attributes.Description, *actual.Data.Attributes.Description)
	require.Equal(t, *expected.Data.Attributes.Version, *actual.Data.Attributes.Version)
}
コード例 #23
0
func TestUnwantedCharactersRelatedToSearchLogic(t *testing.T) {
	resource.Require(t, resource.Database)
	defer cleaner.DeleteCreatedEntities(DB)()
	service := getServiceAsUser()
	wiRepo := workitem.NewWorkItemRepository(DB)

	expectedDescription := rendering.NewMarkupContentFromLegacy("Related to http://example-domain:8080/different-path/ok issue")

	_, err := wiRepo.Create(
		context.Background(),
		workitem.SystemBug,
		map[string]interface{}{
			workitem.SystemTitle:       "specialwordforsearch_new",
			workitem.SystemDescription: expectedDescription,
			workitem.SystemCreator:     "baijum",
			workitem.SystemState:       workitem.SystemStateClosed,
		},
		"")
	require.Nil(t, err)

	controller := NewSearchController(service, gormapplication.NewGormDB(DB))
	// add url: in the query, that is not expected by the code hence need to make sure it gives expected result.
	q := `http://url:some-random-other-domain:8080/different-path/`
	_, sr := test.ShowSearchOK(t, nil, nil, controller, nil, nil, q)
	require.NotNil(t, sr.Data)
	assert.Empty(t, sr.Data)
}
コード例 #24
0
func TestSpacesSearchOK(t *testing.T) {
	resource.Require(t, resource.Database)

	tester := TestSearchSpaces{}
	tester.db = gormapplication.NewGormDB(DB)
	tester.clean = cleaner.DeleteCreatedEntities(DB)

	idents, err := tester.createTestData()
	if err != nil {
		t.Fatal(err)
	}
	defer tester.cleanTestData()

	tests := []okScenario{
		{"With uppercase fullname query", args{offset("0"), limit(10), "TEST_AB"}, expects{totalCount(1)}},
		{"With lowercase fullname query", args{offset("0"), limit(10), "TEST_AB"}, expects{totalCount(1)}},
		{"With uppercase description query", args{offset("0"), limit(10), "DESCRIPTION FOR TEST_AB"}, expects{totalCount(1)}},
		{"With lowercase description query", args{offset("0"), limit(10), "description for test_ab"}, expects{totalCount(1)}},
		{"with special chars", args{offset("0"), limit(10), "&:\n!#%?*"}, expects{totalCount(0)}},
		{"with * to list all", args{offset("0"), limit(10), "*"}, expects{totalCountAtLeast(len(idents))}},
		{"with multi page", args{offset("0"), limit(10), "TEST"}, expects{hasLinks("Next")}},
		{"with last page", args{offset(strconv.Itoa(len(idents) - 1)), limit(10), "TEST"}, expects{hasNoLinks("Next"), hasLinks("Prev")}},
		{"with different values", args{offset("0"), limit(10), "TEST"}, expects{differentValues()}},
	}

	service := goa.New("TestSpacesSearch-Service")
	controller := NewSearchController(service, tester.db)

	for _, tt := range tests {
		_, result := test.SpacesSearchOK(t, context.Background(), service, controller, tt.args.pageLimit, tt.args.pageOffset, tt.args.q)
		for _, expect := range tt.expects {
			expect(t, tt, result)
		}
	}
}
コード例 #25
0
func TestSearchPagination(t *testing.T) {
	resource.Require(t, resource.Database)
	defer cleaner.DeleteCreatedEntities(DB)()
	service := getServiceAsUser()

	wiRepo := workitem.NewWorkItemRepository(DB)

	_, err := wiRepo.Create(
		context.Background(),
		workitem.SystemBug,
		map[string]interface{}{
			workitem.SystemTitle:       "specialwordforsearch2",
			workitem.SystemDescription: nil,
			workitem.SystemCreator:     "baijum",
			workitem.SystemState:       workitem.SystemStateClosed,
		},
		"")
	require.Nil(t, err)

	controller := NewSearchController(service, gormapplication.NewGormDB(DB))
	q := "specialwordforsearch2"
	_, sr := test.ShowSearchOK(t, nil, nil, controller, nil, nil, q)

	// defaults in paging.go is 'pageSizeDefault = 20'
	assert.Equal(t, "http:///api/search?page[offset]=0&page[limit]=20&q=specialwordforsearch2", *sr.Links.First)
	assert.Equal(t, "http:///api/search?page[offset]=0&page[limit]=20&q=specialwordforsearch2", *sr.Links.Last)
	require.NotEmpty(t, sr.Data)
	r := sr.Data[0]
	assert.Equal(t, "specialwordforsearch2", r.Attributes[workitem.SystemTitle])
}
コード例 #26
0
ファイル: area_test.go プロジェクト: Ritsyy/almighty-core
func (rest *TestAreaREST) TestFailShowAreaNotFound() {
	t := rest.T()
	resource.Require(t, resource.Database)

	svc, ctrl := rest.SecuredController()
	test.ShowAreaNotFound(t, svc.Context, svc, ctrl, uuid.NewV4().String())
}
コード例 #27
0
ファイル: area_test.go プロジェクト: Ritsyy/almighty-core
func (rest *TestAreaREST) TestSuccessCreateMultiChildArea() {
	t := rest.T()
	resource.Require(t, resource.Database)

	/*
		Area 2 ---> Area 21-0 ----> Area 21-0-0
	*/

	parentID := createSpaceAndArea(t, rest.db).ID
	name := "Area 21-0"
	ci := createChildArea(&name)

	svc, ctrl := rest.SecuredController()
	_, created := test.CreateChildAreaCreated(t, svc.Context, svc, ctrl, parentID.String(), ci)
	assert.Equal(t, *ci.Data.Attributes.Name, *created.Data.Attributes.Name)
	assert.Equal(t, parentID.String(), *created.Data.Relationships.Parent.Data.ID)

	// Create a child of the child created above.
	name = "Area 21-0-0"
	ci = createChildArea(&name)
	newParentID := *created.Data.Relationships.Parent.Data.ID
	_, created = test.CreateChildAreaCreated(t, svc.Context, svc, ctrl, newParentID, ci)
	assert.Equal(t, *ci.Data.Attributes.Name, *created.Data.Attributes.Name)
	assert.NotNil(t, *created.Data.Attributes.CreatedAt)
	assert.NotNil(t, *created.Data.Attributes.Version)
	assert.Equal(t, newParentID, *created.Data.Relationships.Parent.Data.ID)
	assert.Contains(t, *created.Data.Relationships.Children.Links.Self, "children")

}
コード例 #28
0
func TestGravatarURLGeneration(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)
	grURL, err := generateGravatarURL("*****@*****.**")
	assert.Nil(t, err)
	assert.Equal(t, "https://www.gravatar.com/avatar/0fa6cfaa2812a200c566f671803cdf2d.jpg", grURL)
}
コード例 #29
0
func (test *TestIterationRepository) TestCreateChildIteration() {
	t := test.T()
	resource.Require(t, resource.Database)

	repo := iteration.NewIterationRepository(test.DB)

	start := time.Now()
	end := start.Add(time.Hour * (24 * 8 * 3))
	name := "Sprint #24"
	name2 := "Sprint #24.1"

	i := iteration.Iteration{
		Name:    name,
		SpaceID: uuid.NewV4(),
		StartAt: &start,
		EndAt:   &end,
	}
	repo.Create(context.Background(), &i)

	i2 := iteration.Iteration{
		Name:     name2,
		SpaceID:  uuid.NewV4(),
		StartAt:  &start,
		EndAt:    &end,
		ParentID: i.ID,
	}
	repo.Create(context.Background(), &i2)

	i2L, err := repo.Load(context.Background(), i2.ID)
	require.Nil(t, err)
	assert.NotEqual(t, uuid.Nil, i2.ParentID)
	assert.Equal(t, i2.ParentID, i2L.ParentID)
}
コード例 #30
0
func TestListTypeConversion(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)

	data := []input{
		{intList, [2]int{11, 2}, "array/slice", false},
		{intList, [2]string{"11", "2"}, nil, true},

		{strList, [2]string{"11", "2"}, "array/slice", false},
		{strList, [2]int{11, 2}, nil, true},
	}

	for _, inp := range data {
		// Ignore expectedValue for now.
		// slices can be compared only with nil.
		// Because we will need to iterate and match the output.
		retVal, err := inp.t.ConvertToModel(inp.value)
		if (err != nil) == inp.errorExpected {
			t.Log("test pass for input: ", inp)
		} else {
			t.Error("failed for input=", inp)
			t.Error(retVal, err)
			t.Fail()
		}
	}
}