Skip to content

Commit

Permalink
added some basic tests and fixed config marchaling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nxy7 committed Jun 22, 2023
1 parent dacc425 commit c811f0f
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Monorepo management tool that's extensible and will fit any workflow.
- Extensible using any shell that's available on the system. ☑
- Discoverable: allows newcomers to easily find out all parts of the system they can interact with. ☑
- Smart testing makes CI pipelines faster. ☒
- Integrates with other tools like telepresence. ☒
- Post command hooks allow you to run script after specific command. ☒
- Integrates with other tools like telepresence. ☑
- Works with Docker Compose, Kubernetes and standalone apps. ☑
- Composable: configuration can be split into many files. ☑
- Commands work from any directory within repository. ☑
Expand Down
28 changes: 28 additions & 0 deletions cmd/command_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cmd

import (
"encoding/json"

"optimus/config"
"testing"
)

func TestCommandCanBeMarchaled(t *testing.T) {
c := &config.Cmd{
Run: "",
Path: "",
Name: "",
Description: "",
File: "",
Shell: "",
CommandFunc: func() error {
println("elo co tam")
return nil
},
}

_, err := json.MarshalIndent(c, "", " ")
if err != nil {
panic(err)
}
}
10 changes: 10 additions & 0 deletions cmd/printConfig_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cmd

import (
"testing"
)

func TestConfigCanBeMarchaled(t *testing.T) {
// Execute()
printConfigCmd.Run(nil, []string{""})
}
24 changes: 24 additions & 0 deletions config/command.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package config

import (
"encoding/json"
"fmt"
"log"

// "optimus/utils"

"os"
"os/exec"

// "strings"

"github.com/spf13/cobra"
Expand All @@ -22,6 +25,27 @@ type Cmd struct {
CommandFunc func() error
}

func (c Cmd) MarshalJSON() ([]byte, error) {
fmt.Println("elo")
return json.Marshal(&struct {
Run string
Path string
Name string
Description string
File string
Shell string
CommandFunc string
}{
Run: c.Run,
Path: c.Path,
Name: c.Name,
Description: c.Description,
File: c.File,
Shell: c.Shell,
CommandFunc: "Function",
})
}

func ParseCmd(name string, root string, a any) Cmd {
command := Cmd{
Run: "",
Expand Down
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ func TestLoadConfig(t *testing.T) {
}
fmt.Printf("c: %v\n", string(j))
}

func TestConfigCanBeMarchaled(t *testing.T) {

}
16 changes: 0 additions & 16 deletions start/start.go

This file was deleted.

7 changes: 7 additions & 0 deletions test/countsErrors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package test

import "testing"

func TestCountsErrorsProperly(t *testing.T) {

}
2 changes: 1 addition & 1 deletion utils/project_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ProjectRoot() string {
return ""
})()
if p == "" {
panic("no path found")
panic("Not a git repository")
}

return p
Expand Down
14 changes: 14 additions & 0 deletions utils/project_root_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package utils

import (
"os"
"testing"
)

func TestReturnsPath(t *testing.T) {
p := ProjectRoot()
_, err := os.ReadDir(p)
if err != nil {
t.Error(err)
}
}

0 comments on commit c811f0f

Please sign in to comment.