Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Add testing framework and simple first test (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
stiangrindvoll authored Nov 21, 2017
1 parent 6653231 commit b48ee52
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ sudo: false
go:
- 1.x

script:
- make

before_deploy:
- make build-all

deploy:
provider: releases
api_key:
Expand Down
20 changes: 19 additions & 1 deletion Gopkg.lock

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

9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
VERSION := $(shell git describe --tags)
BUILD_DIR?=$(shell pwd)/build
NAME=rio
DIRECTORIES=./ ./cmd ./rmq ./file

all: tools deps build-all compress
all: tools deps test

tools:
go get -u github.com/golang/dep/cmd/dep
Expand All @@ -11,6 +12,10 @@ tools:
deps:
dep ensure

test:
go vet ${DIRECTORIES}
go test -v ${DIRECTORIES}

build:
go build -o ${NAME} -ldflags "-X main.version=${VERSION}" main.go

Expand All @@ -22,7 +27,7 @@ build-all:
-output="${BUILD_DIR}/${NAME}-${VERSION}-{{.OS}}-{{.Arch}}"

compress:
gzip -v ${BUILD_DIR}/*
gzip -f -v ${BUILD_DIR}/*

clean:
rm -rf ./build
Expand Down
33 changes: 33 additions & 0 deletions rmq/message_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright © 2017 Meltwater
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package rmq

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestNewMessageFromAttrs(t *testing.T) {
var headers = make(map[string]string)
headers["amqp.routingKey"] = "routingKey from tarball header"
headers["myHeaderString"] = "myString"

m := *NewMessageFromAttrs([]byte("Message"), headers)

assert.Equal(t, "routingKey from tarball header", m.RoutingKey)
assert.Equal(t, []byte("Message"), m.Body)
assert.Equal(t, "myString", m.Headers["myHeaderString"])
}

0 comments on commit b48ee52

Please sign in to comment.