コード例 #1
0
func TestOneLevelGroup(t *testing.T) {
	program := data.Program{}
	program.AcademicProgram.ProgramId = "Test"
	program.AcademicProgram.Description = sql.NullString{String: "Test Program", Valid: true}
	program.ProgramGroups = generateGroups(1, 1)
	out, err := Convert(program)
	if err != nil {
		t.Error(err)
	}

	if len(out.Requirements) != 1 {
		t.Log(fmt.Sprintf("Wrong number of requirements! %d != 1\n", len(out.Requirements)))
		t.Fail()
	}

	if len(out.Requirements[0].Requirements) != 0 {
		t.Log(fmt.Sprintf("Wrong number of child requirements! %d != 0\n", len(out.Requirements[0].Requirements)))
		t.Fail()
	}

	if len(out.Requirements[0].Specifications) != 0 {
		t.Log(fmt.Sprintf("Wrong number of child specifications! %d != 0\n", len(out.Requirements[0].Specifications)))
		t.Fail()
	}

	json, err := json.MarshalIndent(out, "", "    ")
	if err != nil {
		t.Error(err)
	}
	t.Log(string(json))
}
コード例 #2
0
func TestGroupWithText(t *testing.T) {
	program := data.Program{}
	program.AcademicProgram.ProgramId = "Test"
	program.AcademicProgram.Description = sql.NullString{String: "Test Program", Valid: true}
	program.ProgramGroups = generateGroups(1, 1)
	program.ProgramTexts = []model.ProgramText{
		{
			ProgramId:         "Test",
			ParentGroupNumber: 1,
			SequenceNumber:    2,
			GroupText:         "TEST TEXT",
			Description:       "Test Description",
		},
	}

	out, err := Convert(program)
	if err != nil {
		t.Error(err)
	}

	j, err := json.MarshalIndent(out, "", "    ")
	if err != nil {
		t.Error(err)
	}
	t.Log(string(j))

	if len(out.Requirements) != 1 {
		t.Log(fmt.Sprintf("Wrong number of child Requirements! %d != 1\n", len(out.Requirements)))
		t.Fail()
	}

	if len(out.Notes) != 0 {
		t.Log(fmt.Sprintf("Wrong number of notes! %d != 0\n", len(out.Notes)))
		t.Fail()
	}

	if len(out.Requirements[0].Notes) != 1 {
		t.Log(fmt.Sprintf("Wrong number of (grand)child notes! %d != 1\n", len(out.Requirements[0].Notes)))
		t.Fail()
	}
}