Skip to content

Commit

Permalink
fix warnings.
Browse files Browse the repository at this point in the history
change command name.
  • Loading branch information
[email protected] authored and chermehdi committed Feb 22, 2020
1 parent bf7b870 commit 7925ed5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 34 deletions.
16 changes: 8 additions & 8 deletions commands/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ func getDefaultConfiguration() *config.Config {
}

func TestSetConfiguration(t *testing.T) {
config := getDefaultConfiguration()
configuration := getDefaultConfiguration()

UpdateConfiguration(config, "server.port", "1245")
_ = UpdateConfiguration(configuration, "server.port", "1245")

assert.Equal(t, config.Server.Port, 1245)
assert.Equal(t, config.Lang.Default, "cpp")
assert.Equal(t, configuration.Server.Port, 1245)
assert.Equal(t, configuration.Lang.Default, "cpp")

UpdateConfiguration(config, "lang.default", "java")
assert.Equal(t, config.Lang.Default, "java")
_ = UpdateConfiguration(configuration, "lang.default", "java")
assert.Equal(t, configuration.Lang.Default, "java")
}

func TestSetConfigurationUnknownKey(t *testing.T) {
config := getDefaultConfiguration()
err := UpdateConfiguration(config, "unkown.key", "123")
configuration := getDefaultConfiguration()
err := UpdateConfiguration(configuration, "unkown.key", "123")

assert.Error(t, err, "Error should be returned if the key is unknown")
}
21 changes: 1 addition & 20 deletions commands/parse.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"bytes"
"context"
json2 "encoding/json"
"fmt"
Expand All @@ -20,17 +19,6 @@ import (

const listenAddr = ":4243"

// Serialize task into a JSON string.
func SerializeTask(meta EgorMeta) (string, error) {
var buffer bytes.Buffer
encoder := json2.NewEncoder(&buffer)
if err := encoder.Encode(meta); err != nil {
return "", err
}
return buffer.String(), nil
}


func CreateDirectoryStructure(task Task, config Config, rootDir string) (string, error) {
taskDir := path.Join(rootDir, task.Name)
if err := os.Mkdir(taskDir, 0777); err != nil {
Expand Down Expand Up @@ -140,7 +128,7 @@ func waitForShutDown(server *http.Server, done chan<- string, quit <-chan string
done <- content
}

func ParseAction(context *cli.Context) error {
func ParseAction(_ *cli.Context) error {
msgReceiveChannel := make(chan string, 1)
msgReadChannel := make(chan string, 1)

Expand Down Expand Up @@ -189,11 +177,4 @@ var ParseCommand = cli.Command{
Usage: "Parse a task using 'Competitive Companion'",
UsageText: "parse task from navigator",
Action: ParseAction,
//Flags: []cli.Flag{
// //&cli.BoolFlag{
// // Name: "cd",
// // Aliases: []string{"c"},
// // Usage: "Change to task directory after creating the task",
// //},
//},
}
6 changes: 3 additions & 3 deletions commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type DiffChecker struct {
}

func (c *DiffChecker) Check(got, expected string) error {
// Compre the trimmed output from both input and output
// Compare the trimmed output from both input and output
if strings.Trim(got, " \t\n\r") != strings.Trim(expected, " \t\n\r") {
return errors.New(fmt.Sprintf("Checker failed, expected %s, found %s", got, expected))
}
Expand Down Expand Up @@ -59,8 +59,8 @@ func RunAction(context *cli.Context) error {
return nil
}

var RunCommand = cli.Command{
Name: "run",
var TestCommand = cli.Command{
Name: "test",
Aliases: []string{"r"},
Usage: "Run the current task testcases",
UsageText: "Run the current task testcases",
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package main

import (
"bytes"
"html/template"
"log"
"os"
"github.com/chermehdi/egor/commands"
"github.com/chermehdi/egor/config"
"github.com/urfave/cli/v2"
"html/template"
"log"
"os"
)

const Egor = `
Expand Down Expand Up @@ -45,6 +45,7 @@ func main() {
&commands.ConfigCommand,
&commands.CaseCommand,
&commands.ShowCasesCommand,
&commands.TestCommand,
},
}

Expand Down

0 comments on commit 7925ed5

Please sign in to comment.