• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GothenburgBitFactory / taskwarrior / 12343201393

15 Dec 2024 11:30PM UTC coverage: 84.419% (-1.1%) from 85.522%
12343201393

Pull #3724

github

web-flow
Merge 532931b9f into ddae5c4ba
Pull Request #3724: Support importing Taskwarrior v2.x data files

15 of 145 new or added lines in 4 files covered. (10.34%)

183 existing lines in 48 files now uncovered.

19289 of 22849 relevant lines covered (84.42%)

23168.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.33
/test/tdb2_test.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included
13
// in all copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
//
23
// https://www.opensource.org/licenses/mit-license.php
24
//
25
////////////////////////////////////////////////////////////////////////////////
26

27
#include <cmake.h>
28
// cmake.h include header must come first
29

30
#include <main.h>
31
#include <stdlib.h>
32
#include <test.h>
33
#include <unistd.h>
34

35
#include <iostream>
36

37
namespace {
38

39
void cleardb() {
1✔
40
  // Remove any residual test files.
41
  rmdir("./extensions");
1✔
42
  unlink("./taskchampion.sqlite3");
1✔
43
}
1✔
44

45
}  // namespace
46

47
////////////////////////////////////////////////////////////////////////////////
48
int TEST_NAME(int, char**) {
1✔
49
  UnitTest t(12);
1✔
50
  Context context;
1✔
51
  Context::setContext(&context);
1✔
52

53
  // Ensure environment has no influence.
54
  unsetenv("TASKDATA");
1✔
55
  unsetenv("TASKRC");
1✔
56

57
  try {
58
    cleardb();
1✔
59

60
    // Set the context to allow GC.
61
    context.config.set("gc", 1);
2✔
62
    context.config.set("debug", 1);
2✔
63

64
    context.tdb2.open_replica(".", true);
1✔
65

66
    // Try reading an empty database.
67
    std::vector<Task> pending = context.tdb2.pending_tasks();
1✔
68
    std::vector<Task> completed = context.tdb2.completed_tasks();
1✔
69
    int num_reverts_possible = context.tdb2.num_reverts_possible();
1✔
70
    int num_local_changes = context.tdb2.num_local_changes();
1✔
71

72
    t.is((int)pending.size(), 0, "TDB2 Read empty pending");
2✔
73
    t.is((int)completed.size(), 0, "TDB2 Read empty completed");
2✔
74
    t.is((int)num_reverts_possible, 0, "TDB2 Read empty undo");
2✔
75
    t.is((int)num_local_changes, 0, "TDB2 Read empty backlog");
2✔
76

77
    // Add a task.
78
    Task task(R"([description:"description" name:"value"])");
2✔
79
    context.tdb2.add(task);
×
80

81
    pending = context.tdb2.pending_tasks();
×
82
    completed = context.tdb2.completed_tasks();
×
83
    num_reverts_possible = context.tdb2.num_reverts_possible();
×
84
    num_local_changes = context.tdb2.num_local_changes();
×
85

86
    t.is((int)pending.size(), 1, "TDB2 after add, 1 pending task");
×
87
    t.is((int)completed.size(), 0, "TDB2 after add, 0 completed tasks");
×
88
    t.is((int)num_reverts_possible, 1, "TDB2 after add, 1 revert possible");
×
89
    t.is((int)num_local_changes, 6, "TDB2 after add, 6 local changes");
×
90

91
    task.set("description", "This is a test");
×
92
    context.tdb2.modify(task);
×
93

94
    pending = context.tdb2.pending_tasks();
×
95
    completed = context.tdb2.completed_tasks();
×
96
    num_reverts_possible = context.tdb2.num_reverts_possible();
×
97
    num_local_changes = context.tdb2.num_local_changes();
×
98

99
    t.is((int)pending.size(), 1, "TDB2 after set, 1 pending task");
×
100
    t.is((int)completed.size(), 0, "TDB2 after set, 0 completed tasks");
×
101
    t.is((int)num_reverts_possible, 1, "TDB2 after set, 1 revert possible");
×
102

103
    // At this point, there may be 7 or 8 local changes, depending on whether
104
    // the `modified` property changed between the `add` and `modify`
105
    // invocation. That only happens if the clock ticks over to the next second
106
    // between those invocations.
107
    t.ok(num_local_changes == 7 || num_local_changes == 8, "TDB2 after set, 7 or 8 local changes");
×
108

109
    // Reset for reuse.
110
    cleardb();
×
111
    context.tdb2.open_replica(".", true);
×
112

113
    // TODO complete a task
114
    // TODO gc
115
  }
2✔
116

117
  catch (const std::string& error) {
1✔
118
    t.diag(error);
1✔
119
    return -1;
1✔
120
  }
1✔
121

122
  catch (...) {
×
123
    t.diag("Unknown error.");
×
124
    return -2;
×
UNCOV
125
  }
×
126

127
  rmdir("./extensions");
×
128
  unlink("./pending.data");
×
129
  unlink("./completed.data");
×
130
  unlink("./undo.data");
×
131
  unlink("./backlog.data");
×
132

133
  return 0;
×
134
}
1✔
135

136
////////////////////////////////////////////////////////////////////////////////
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc