Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions githubtasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc"

pb "github.com/brotherlogic/githubtasks/proto"
pbg "github.com/brotherlogic/goserver/proto"
)

const (
// KEY where the config is stored
KEY = "/github.com/brotherlogic/githubtasks/config"
)

//Server main server type
type Server struct {
*goserver.GoServer
config *pb.Config
}

// Init builds the server
Expand Down Expand Up @@ -53,6 +60,20 @@ func (s *Server) GetState() []*pbg.State {
}
}

func (s *Server) save(ctx context.Context) {
s.KSclient.Save(ctx, KEY, s.config)
}

func (s *Server) load(ctx context.Context) error {
data, _, err := s.KSclient.Read(ctx, KEY, s.config)
if err != nil {
return err
}

s.config = data.(*pb.Config)
return nil
}

func main() {
var quiet = flag.Bool("quiet", false, "Show all output")
flag.Parse()
Expand Down
2 changes: 1 addition & 1 deletion githubtasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package main
import "testing"

func TestNothing(t *testing.T) {
dummy()

}
13 changes: 12 additions & 1 deletion githubtasksutils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
package main

func dummy() {
import (
"fmt"

"golang.org/x/net/context"
)

func (s *Server) validateIntegrity(ctx context.Context) error {
if len(s.config.GetProjects()) == 0 {
s.RaiseIssue(ctx, "Task Issue", fmt.Sprintf("There are no projects listed"), false)
}

return nil
}
25 changes: 25 additions & 0 deletions githubtasksutils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"context"
"testing"

"github.com/brotherlogic/keystore/client"
)

func InitTestServer() *Server {
s := Init()
s.SkipLog = true
s.SkipIssue = true
s.GoServer.KSclient = *keystoreclient.GetTestClient(".test")
return s
}

func TestEmptyConfig(t *testing.T) {
s := InitTestServer()
err := s.validateIntegrity(context.Background())

if err != nil {
t.Errorf("Error in validation")
}
}
133 changes: 87 additions & 46 deletions proto/githubtasks.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions proto/githubtasks.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ syntax = "proto3";

package githubtasks;

message config {
repeated Project projects = 1;
}

message Project {
string name = 1;
repeated Milestone milestones = 2;
Expand Down