Permalink
Browse files

Started work on implmenting interface for status crud ops on filesystem

Now that the core has the interface for CRUD operations, I'm
implementing the interface in the CLI. The implementation in the CLI
will work with the statuses.yaml file to carry out the crud operations.

Someday I might write an implementation to deal with sqlite based
storage but today is not that day
  • Loading branch information...
kiriappeee committed May 10, 2018
1 parent 603704a commit cb2b9c74f985522c25e02f356055eab5818f37b5
Showing with 49 additions and 0 deletions.
  1. +31 −0 statuscrud_file.go
  2. +18 −0 statuscrud_file_test.go
@@ -0,0 +1,31 @@
package main

import (
"github.com/kiriappeee/slack-status-updater-core"
)

type statusCRUDFileImplementation string

func (s statusCRUDFileImplementation) GetStatuses() []ssucore.Status {
return []ssucore.Status{
ssucore.Status{"test", "emojiA", "Status One"},
ssucore.Status{"test1", "emojiB", "Status Two"},
ssucore.Status{"test2", "emojiC", "Status Three"},
ssucore.Status{"test3", "emojiD", "Status Four"},
}
}

func (s statusCRUDFileImplementation) GetStatusByKey(name string) (ssucore.Status, error) {
//stub
return ssucore.Status{}, nil
}

func (s statusCRUDFileImplementation) AddNewStatus(status ssucore.Status) error {
//stub
return nil
}

func (s statusCRUDFileImplementation) DeleteStatusByName(name string) error {
//stub
return nil
}
@@ -0,0 +1,18 @@
package main

import (
"os"
"testing"

"github.com/kiriappeee/slack-status-updater-core"
)

func TestStatusesCanBeListed(t *testing.T) {
var sci ssucore.StatusCRUDInterface
homeDirectory := os.Getenv("HOME")
sci = statusCRUDFileImplementation(homeDirectory + "/.config/ssuclitest/statuses.yaml")
statuses := ssucore.GetStatuses(sci)
if len(statuses) != 4 {
t.Fatalf("Did not receive the expected statuses")
}
}

0 comments on commit cb2b9c7

Please sign in to comment.