aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operations
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-13 16:13:40 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-13 16:13:40 +0200
commitbc12fee58e8bd86672793ae37d9f924158afb482 (patch)
treeb6506af647a5e6d3d8c053f2b284a3adc335d35b /bug/operations
parente02294c8f372156945bbc43d70d4d36a07a3fbcf (diff)
downloadgit-bug-bc12fee58e8bd86672793ae37d9f924158afb482.tar.gz
create the Bug structure
Diffstat (limited to 'bug/operations')
-rw-r--r--bug/operations/create.go6
-rw-r--r--bug/operations/operation.go19
-rw-r--r--bug/operations/operation_test.go16
-rw-r--r--bug/operations/set_title.go6
4 files changed, 14 insertions, 33 deletions
diff --git a/bug/operations/create.go b/bug/operations/create.go
index f004a12b..57cca907 100644
--- a/bug/operations/create.go
+++ b/bug/operations/create.go
@@ -7,7 +7,7 @@ import (
// CreateOperation define the initial creation of a bug
-var _ Operation = CreateOperation{}
+var _ bug.Operation = CreateOperation{}
type CreateOperation struct {
Title string
@@ -23,8 +23,8 @@ func NewCreateOp(author bug.Person, title, message string) CreateOperation {
}
}
-func (op CreateOperation) OpType() OperationType {
- return CREATE
+func (op CreateOperation) OpType() bug.OperationType {
+ return bug.CREATE
}
func (op CreateOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
diff --git a/bug/operations/operation.go b/bug/operations/operation.go
deleted file mode 100644
index a9cf806f..00000000
--- a/bug/operations/operation.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package operations
-
-import (
- "github.com/MichaelMure/git-bug/bug"
-)
-
-type OperationType int
-
-const (
- UNKNOW OperationType = iota
- CREATE
- SET_TITLE
- ADD_COMMENT
-)
-
-type Operation interface {
- OpType() OperationType
- Apply(snapshot bug.Snapshot) bug.Snapshot
-}
diff --git a/bug/operations/operation_test.go b/bug/operations/operation_test.go
index 1bd15f78..e53e524b 100644
--- a/bug/operations/operation_test.go
+++ b/bug/operations/operation_test.go
@@ -11,8 +11,8 @@ type CreateOperation2 struct {
Message string
}
-func (op CreateOperation2) OpType() OperationType {
- return UNKNOW
+func (op CreateOperation2) OpType() bug.OperationType {
+ return bug.UNKNOW
}
func (op CreateOperation2) Apply(snapshot bug.Snapshot) bug.Snapshot {
@@ -26,16 +26,16 @@ func TestOperationsEquality(t *testing.T) {
Email: "rene@descartes.fr",
}
- var A Operation = NewCreateOp(rene, "title", "message")
- var B Operation = NewCreateOp(rene, "title", "message")
- var C Operation = NewCreateOp(rene, "title", "different message")
+ var A bug.Operation = NewCreateOp(rene, "title", "message")
+ var B bug.Operation = NewCreateOp(rene, "title", "message")
+ var C bug.Operation = NewCreateOp(rene, "title", "different message")
if A != B {
- t.Fatal("Equal value operations should be tested equals")
+ t.Fatal("Equal value ops should be tested equals")
}
if A == C {
- t.Fatal("Different value operations should be tested different")
+ t.Fatal("Different value ops should be tested different")
}
D := CreateOperation2{Title: "title", Message: "message"}
@@ -49,7 +49,7 @@ func TestOperationsEquality(t *testing.T) {
Email: "isaac@newton.uk",
}
- var E Operation = NewCreateOp(isaac, "title", "message")
+ var E bug.Operation = NewCreateOp(isaac, "title", "message")
if A == E {
t.Fatal("Operation equality should handle the author")
diff --git a/bug/operations/set_title.go b/bug/operations/set_title.go
index 0d935db6..1e2ef20a 100644
--- a/bug/operations/set_title.go
+++ b/bug/operations/set_title.go
@@ -2,7 +2,7 @@ package operations
import "github.com/MichaelMure/git-bug/bug"
-var _ Operation = SetTitleOperation{}
+var _ bug.Operation = SetTitleOperation{}
type SetTitleOperation struct {
Title string
@@ -14,8 +14,8 @@ func NewSetTitleOp(title string) SetTitleOperation {
}
}
-func (op SetTitleOperation) OpType() OperationType {
- return SET_TITLE
+func (op SetTitleOperation) OpType() bug.OperationType {
+ return bug.SET_TITLE
}
func (op SetTitleOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {