diff --git a/lockable.go b/lockable.go index f5244b6..80cf847 100644 --- a/lockable.go +++ b/lockable.go @@ -429,7 +429,7 @@ func (lockable * BaseLockable) Unlock(node GraphNode, state LockableState) error return nil } -func NewLockable(ctx * GraphContext, name string, requirements []Lockable) (* BaseLockable, error) { +func NewBaseLockable(ctx * GraphContext, name string, requirements []Lockable) (* BaseLockable, error) { state := NewBaseLockableState(name) lockable := &BaseLockable{ BaseNode: NewNode(ctx, RandID(), &state), diff --git a/lockable_test.go b/lockable_test.go index 829b483..d059615 100644 --- a/lockable_test.go +++ b/lockable_test.go @@ -7,23 +7,23 @@ import ( "time" ) -func TestNewLockable(t * testing.T) { +func TestNewBaseLockable(t * testing.T) { ctx := testContext(t) - r1, err := NewLockable(ctx, "Test lockable 1", []Lockable{}) + r1, err := NewBaseLockable(ctx, "Test lockable 1", []Lockable{}) fatalErr(t, err) - _, err = NewLockable(ctx, "Test lockable 2", []Lockable{r1}) + _, err = NewBaseLockable(ctx, "Test lockable 2", []Lockable{r1}) fatalErr(t, err) } func TestRepeatedChildLockable(t * testing.T) { ctx := testContext(t) - r1, err := NewLockable(ctx, "Test lockable 1", []Lockable{}) + r1, err := NewBaseLockable(ctx, "Test lockable 1", []Lockable{}) fatalErr(t, err) - _, err = NewLockable(ctx, "Test lockable 2", []Lockable{r1, r1}) + _, err = NewBaseLockable(ctx, "Test lockable 2", []Lockable{r1, r1}) if err == nil { t.Fatal("Added the same lockable as a child twice to the same lockable") } @@ -32,7 +32,7 @@ func TestRepeatedChildLockable(t * testing.T) { func TestLockableSelfLock(t * testing.T) { ctx := testContext(t) - r1, err := NewLockable(ctx, "Test lockable 1", []Lockable{}) + r1, err := NewBaseLockable(ctx, "Test lockable 1", []Lockable{}) fatalErr(t, err) err = LockLockable(ctx, r1, r1, nil) @@ -64,13 +64,13 @@ func TestLockableSelfLock(t * testing.T) { func TestLockableSelfLockTiered(t * testing.T) { ctx := testContext(t) - r1, err := NewLockable(ctx, "Test lockable 1", []Lockable{}) + r1, err := NewBaseLockable(ctx, "Test lockable 1", []Lockable{}) fatalErr(t, err) - r2, err := NewLockable(ctx, "Test lockable 2", []Lockable{}) + r2, err := NewBaseLockable(ctx, "Test lockable 2", []Lockable{}) fatalErr(t, err) - r3, err := NewLockable(ctx, "Test lockable 3", []Lockable{r1, r2}) + r3, err := NewBaseLockable(ctx, "Test lockable 3", []Lockable{r1, r2}) fatalErr(t, err) err = LockLockable(ctx, r3, r3, nil) @@ -120,10 +120,10 @@ func TestLockableSelfLockTiered(t * testing.T) { func TestLockableLockOther(t * testing.T) { ctx := testContext(t) - r1, err := NewLockable(ctx, "Test lockable 1", []Lockable{}) + r1, err := NewBaseLockable(ctx, "Test lockable 1", []Lockable{}) fatalErr(t, err) - r2, err := NewLockable(ctx, "Test lockable 2", []Lockable{}) + r2, err := NewBaseLockable(ctx, "Test lockable 2", []Lockable{}) fatalErr(t, err) _, err = UpdateStates(ctx, []GraphNode{r2}, func(states []NodeState) ([]NodeState, interface{}, error) { @@ -167,10 +167,10 @@ func TestLockableLockOther(t * testing.T) { func TestLockableLockSimpleConflict(t * testing.T) { ctx := testContext(t) - r1, err := NewLockable(ctx, "Test lockable 1", []Lockable{}) + r1, err := NewBaseLockable(ctx, "Test lockable 1", []Lockable{}) fatalErr(t, err) - r2, err := NewLockable(ctx, "Test lockable 2", []Lockable{}) + r2, err := NewBaseLockable(ctx, "Test lockable 2", []Lockable{}) fatalErr(t, err) err = LockLockable(ctx, r1, r1, nil) @@ -215,13 +215,13 @@ func TestLockableLockSimpleConflict(t * testing.T) { func TestLockableLockTieredConflict(t * testing.T) { ctx := testContext(t) - r1, err := NewLockable(ctx, "Test lockable 1", []Lockable{}) + r1, err := NewBaseLockable(ctx, "Test lockable 1", []Lockable{}) fatalErr(t, err) - r2, err := NewLockable(ctx, "Test lockable 2", []Lockable{r1}) + r2, err := NewBaseLockable(ctx, "Test lockable 2", []Lockable{r1}) fatalErr(t, err) - r3, err := NewLockable(ctx, "Test lockable 3", []Lockable{r1}) + r3, err := NewBaseLockable(ctx, "Test lockable 3", []Lockable{r1}) fatalErr(t, err) err = LockLockable(ctx, r2, r2, nil) @@ -236,7 +236,7 @@ func TestLockableLockTieredConflict(t * testing.T) { func TestLockableSimpleUpdate(t * testing.T) { ctx := testContext(t) - l1, err := NewLockable(ctx, "Test Lockable 1", []Lockable{}) + l1, err := NewBaseLockable(ctx, "Test Lockable 1", []Lockable{}) fatalErr(t, err) update_channel := l1.UpdateChannel(0) @@ -251,13 +251,13 @@ func TestLockableSimpleUpdate(t * testing.T) { func TestLockableDownUpdate(t * testing.T) { ctx := testContext(t) - l1, err := NewLockable(ctx, "Test Lockable 1", []Lockable{}) + l1, err := NewBaseLockable(ctx, "Test Lockable 1", []Lockable{}) fatalErr(t, err) - l2, err := NewLockable(ctx, "Test Lockable 2", []Lockable{l1}) + l2, err := NewBaseLockable(ctx, "Test Lockable 2", []Lockable{l1}) fatalErr(t, err) - _, err = NewLockable(ctx, "Test Lockable 3", []Lockable{l2}) + _, err = NewBaseLockable(ctx, "Test Lockable 3", []Lockable{l2}) fatalErr(t, err) update_channel := l1.UpdateChannel(0) @@ -272,13 +272,13 @@ func TestLockableDownUpdate(t * testing.T) { func TestLockableUpUpdate(t * testing.T) { ctx := testContext(t) - l1, err := NewLockable(ctx, "Test Lockable 1", []Lockable{}) + l1, err := NewBaseLockable(ctx, "Test Lockable 1", []Lockable{}) fatalErr(t, err) - l2, err := NewLockable(ctx, "Test Lockable 2", []Lockable{l1}) + l2, err := NewBaseLockable(ctx, "Test Lockable 2", []Lockable{l1}) fatalErr(t, err) - l3, err := NewLockable(ctx, "Test Lockable 3", []Lockable{l2}) + l3, err := NewBaseLockable(ctx, "Test Lockable 3", []Lockable{l2}) fatalErr(t, err) update_channel := l3.UpdateChannel(0) @@ -293,10 +293,10 @@ func TestLockableUpUpdate(t * testing.T) { func TestOwnerNotUpdatedTwice(t * testing.T) { ctx := testContext(t) - l1, err := NewLockable(ctx, "Test Lockable 1", []Lockable{}) + l1, err := NewBaseLockable(ctx, "Test Lockable 1", []Lockable{}) fatalErr(t, err) - l2, err := NewLockable(ctx, "Test Lockable 2", []Lockable{l1}) + l2, err := NewBaseLockable(ctx, "Test Lockable 2", []Lockable{l1}) fatalErr(t, err) update_channel := l2.UpdateChannel(0) diff --git a/thread_test.go b/thread_test.go index 1f97bb9..ff23a77 100644 --- a/thread_test.go +++ b/thread_test.go @@ -34,7 +34,7 @@ func TestNewEvent(t * testing.T) { func TestEventWithRequirement(t * testing.T) { ctx := logTestContext(t, []string{"lockable", "thread"}) - l1, err := NewLockable(ctx, "Test Lockable 1", []Lockable{}) + l1, err := NewBaseLockable(ctx, "Test Lockable 1", []Lockable{}) fatalErr(t, err) t1, err := NewSimpleBaseThread(ctx, "Test Thread 1", []Lockable{l1}, ThreadActions{}, ThreadHandlers{})