-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommand_test.go
More file actions
36 lines (33 loc) · 797 Bytes
/
command_test.go
File metadata and controls
36 lines (33 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) 2019 Meng Huang (mhboy@outlook.com)
// This package is licensed under a MIT license that can be found in the LICENSE file.
package raft
import (
"sync"
"testing"
)
func TestCommand(t *testing.T) {
commands := &commands{types: make(map[uint64]*sync.Pool)}
commands.put(&testCommand{})
if ok := commands.exists(&testCommand{}); ok {
t.Error()
}
if err := commands.register(&testCommand{}); err != nil {
t.Error()
}
cmd := &testCommand{}
if err := commands.register(cmd); err == nil {
t.Error()
}
if cp := commands.clone(cmd.Type()); cp == nil {
t.Error()
}
if cp := commands.clone(cmd.Type() + 1); cp != nil {
t.Error()
}
commands.put(&testCommand{})
if ok := commands.exists(cmd); !ok {
t.Error()
}
command := &DefaultCommand{}
command.Do(nil)
}