Exemple #1
0
func addEntry(project *data.Project) (err error) {
	data.Save(project)
	entry := project.CreateEntryWithDuration(
		getContent(), duration, billable,
	)
	err = data.Save(entry)
	return
}
Exemple #2
0
func TestProjectCreation(t *testing.T) {
	t.Parallel()
	project := data.CreateProject("Test 1")
	project.Company = proto.String("Insight Methods, Inc.")
	if err := data.Save(project); err != nil {
		t.Error(err.Error())
	}
}
Exemple #3
0
func moveEntry(project, newProject *data.Project) error {
	for i, entry := range project.Entries() {
		if i == theIdx {
			entry.Project = newProject
			return data.Save(entry)
		}
	}
	return nil
}
Exemple #4
0
func moveProject(project, newProject *data.Project) error {
	for _, entry := range project.Entries() {
		entry.Project = newProject
		if err := data.Save(entry); err != nil {
			return err
		}
	}

	fmt.Printf("All entries copied to project \"%s\" \n...\n", newProject.GetName())
	return deleteProject(project)
}
Exemple #5
0
func moveProjectOrEntry(project *data.Project) (err error) {
	newProject := data.CreateProject(newName)
	if err = data.Save(newProject); err != nil {
		return err
	}

	if theIdx < 0 {
		return moveProject(project, newProject)
	}

	return moveEntry(project, newProject)
}
Exemple #6
0
func TestTimerCreation(t *testing.T) {
	t.Parallel()
	project := data.CreateProject("Test 2")
	timer := data.CreateTimer(project)
	<-time.After(time.Microsecond)
	if *timer.Started == 0 || *timer.Started < 0 {
		t.Error("timer Started should be greater then 0")
	}
	if err := data.Save(timer); err != nil {
		t.Error(err.Error())
	}
	os.RemoveAll(data.DB.ProjectDirPath(project))
}
Exemple #7
0
func TestTimerLoad(t *testing.T) {
	t.Parallel()
	project := data.CreateProject("Test 4")
	timer := data.CreateTimer(project)

	<-time.After(time.Second)
	if err := data.Save(timer); err != nil {
		t.Error(err.Error())
	}

	<-time.After(10 * time.Millisecond)
	timer2 := data.GetTimer(project)
	if timer2.GetStarted() != timer.GetStarted() {
		t.Fail()
	}
	os.RemoveAll(data.DB.ProjectDirPath(project))
}