Skip to content

Commit

Permalink
Initial Cucumber Tests (#4)
Browse files Browse the repository at this point in the history
* initial test framework checkin

* updated license

* reorganized files
updated docker file to new structure and statically compile

* more file reorganization
  • Loading branch information
ilawjr authored and kcajmagic committed Jan 16, 2019
1 parent 13f7f84 commit f3bb9e7
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cucumber Tests
9 changes: 9 additions & 0 deletions tests/common/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package common

import (
"fmt"
)

func Debug() {
fmt.Println("able to reach glue code")
}
30 changes: 30 additions & 0 deletions tests/features/helloworld/HelloWorld.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Copyright 2019 Comcast Cable Communications Management, LLC
#
# 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.
#
#


Feature: Hello World
The user should see hello world

@HelloWorld001
Scenario Outline: Verify the user sees "<Message>"
When this test case is executed, the user should see "<Message>"
Examples:
| Message |
| Hello World |
| Hallo Welt |
| Bonjour le monde |
| こんにちは世界|
16 changes: 16 additions & 0 deletions tests/runners/travis/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:alpine AS builder

RUN apk update && apk add --no-cache git
COPY ./codex-travis-testrunner /acceptance/src/codex-travis-testrunner
COPY ./common /go/src/common
WORKDIR /acceptance/src/codex-travis-testrunner

RUN go get -d -v

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/codex-travis-testrunner


FROM scratch
COPY --from=builder /go/bin/codex-travis-testrunner /go/bin/codex-travis-testrunner
COPY ./features/helloworld /features
ENTRYPOINT ["/go/bin/codex-travis-testrunner","-feature=/features","-tags=HelloWorld001"]
28 changes: 28 additions & 0 deletions tests/runners/travis/helloworld.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2019 Comcast Cable Communications Management, LLC
*
* 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 main

import "fmt"

func HelloWorld001(msg string) error {

fmt.Println(msg)

return nil

}
53 changes: 53 additions & 0 deletions tests/runners/travis/listener.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright 2019 Comcast Cable Communications Management, LLC
*
* 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 main

import (
"net/http"

"github.com/gorilla/mux"
)

/*
headers:
content-length →21
content-type →application/json
date →Tue, 15 Jan 2019 00:25:58 GMT
x-tr1d1um-build →0.1.1-311
x-tr1d1um-flavor →cherry
x-tr1d1um-region →ch2g
x-tr1d1um-server →tr1d1um-cd-wgs.webpa.comcast.net
x-tr1d1um-start-time →13 Dec 18 03:44 UTC
message body:
{
"message": "Success"
}
*/

func StartListener() {
r := mux.NewRouter()
// caducues-ct.xmidt.comcast.net:8090/api/v2/hook
r.HandleFunc("/api/v2/hook", HandlePostRequest).
Methods("POST")
}

//This will handle just webhook registration. It will validate the registration.
func HandlePostRequest(w http.ResponseWriter, r *http.Request) {

}
62 changes: 62 additions & 0 deletions tests/runners/travis/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright 2019 Comcast Cable Communications Management, LLC
*
* 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 main

import (
"flag"
"fmt"
"os"

"github.com/Comcast/codex/tests/common"

"github.com/DATA-DOG/godog"
)

func main() {
fmt.Println("Start Test Run")
locationoffeaturefiles := flag.String("feature", "", "path to feature files")
tags := flag.String("tags", "", "tags of testcases to be run")
//for travis ci testing:
//waitonlistener := flag.Bool("listenerfirst", false, "Start the listener first, then tests")
flag.Parse()

//wait for webhook registration

//wait for api
common.Debug()
//run tests
status := godog.RunWithOptions("godogs", func(s *godog.Suite) {
FeatureContext(s)
}, godog.Options{
Format: "progress",
Paths: []string{*locationoffeaturefiles},
Tags: *tags,
Concurrency: 1,
NoColors: true,
Output: os.Stdout,
})

fmt.Println("Finish Test Run")
os.Exit(status)
}

func FeatureContext(s *godog.Suite) {

s.Step(`^this test case is executed, the user should see "([^"]*)"$`, HelloWorld001)

}

0 comments on commit f3bb9e7

Please sign in to comment.