Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed Dockerfile, improved Makefile, added client tests
  • Loading branch information
SampleText2k77 committed Dec 16, 2018
commit e4d2f199e0eaa9960fc3af8a2b0344b7748a644b
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM golang:latest

MAINTAINER Alexander Gutyra <gutyra13@gmail.com>

RUN mkdir -p /go/src/goredis
RUN mkdir -p /go/src/GoHomework

COPY . /go/src/goredis
COPY . /go/src/GoHomework

EXPOSE 9090
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ PROJECT_DIR_NAME = GoHomework

CLIENT_RUNFILE_PATH = client/runclient.go
SERVER_RUNFILE_PATH = server/runserver.go
CLIENT_TESTFILE_PATH = client/test/client_test.go
SERVER_TESTFILE_PATH = server/test/server_test.go

make_container:
sudo docker build -t goredis-app .
sudo docker rmi $$(sudo docker images -f "dangling=true" -q)
sudo docker run -d --rm -i --name goredis-app-running goredis-app
sudo docker exec -it goredis-app-running /bin/bash
sudo docker stop goredis-app-running

check:
go vet $(PROJECT_DIR_NAME)/server
go vet $(PROJECT_DIR_NAME)/client
Expand All @@ -16,6 +24,7 @@ build:

test:
go test $(SERVER_TESTFILE_PATH)
go test $(CLIENT_TESTFILE_PATH)

.PHONY: runserver runclient
runserver:
Expand Down
4 changes: 2 additions & 2 deletions client/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func HandleUserRequests(conn net.Conn, done chan string) {
b, _ := reader.ReadByte()

if strings.Compare(string(b), "\t") == 0 {
// commandEnd := completeCommand(buff.String())
// commandEnd := CompleteCommand(buff.String())
// fmt.Fprintln(os.Stdout, commandEnd)
}

Expand Down Expand Up @@ -69,7 +69,7 @@ func SendRequest(conn net.Conn, text string) {
}
}

func completeCommand(commandPart string) string {
func CompleteCommand(commandPart string) string {
commands := [4]string{"SET", "GET", "PUBLISH", "SUBSCRIBE"}

for i := range commands {
Expand Down
19 changes: 19 additions & 0 deletions client/test/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package test

import (
"GoHomework/client/client"
"strings"
"testing"
)

func TestClient(t *testing.T) {
commandEnd := client.CompleteCommand("SUB")
if strings.Compare(commandEnd, "SCRIBE") != 0 {
t.Error("[ERR] CompleteCommand failed. Expected SUB -> SUBSCRIBE, got SUB -> " + commandEnd)
}

commandEnd = client.CompleteCommand("UNKNOWN")
if strings.Compare(commandEnd, "") != 0 {
t.Error("[ERR] CompleteCommand failed. Expected empty, got " + commandEnd)
}
}
4 changes: 0 additions & 4 deletions server/test/server_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package test

// go test server_test.go
// go test -coverprofile cover.out
// go tool cover -html cover.out

import (
"GoHomework/server/server"
"strings"
Expand Down