Skip to content

Commit

Permalink
chore: add proper integ tests to hello-world project
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed May 24, 2018
1 parent 5390993 commit 8e4d6d2
Show file tree
Hide file tree
Showing 10 changed files with 313 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/hello-world/services/hello-container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ FROM node:9-alpine
ENV PORT=8080
EXPOSE ${PORT}

RUN npm install

ADD . /app
WORKDIR /app

RUN npm install
CMD ["npm", "start"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const express = require("express")
const request = require("request-promise")
const express = require("express")

const app = express()

Expand All @@ -8,12 +8,12 @@ const functionEndpoint = process.env.GARDEN_SERVICES_HELLO_FUNCTION_ENDPOINT
app.get("/hello", (req, res) => {
// Query the example cloud function and return the response
request.get(functionEndpoint)
.then(response => {
res.send(response + "\n")
.then(message => {
res.json({ message })
})
.catch(() => {
res.statusCode = 500
res.send("Unable to reach function at " + functionEndpoint + "\n")
res.json({ error: "Unable to reach function at " + functionEndpoint })
})
})

Expand All @@ -22,4 +22,4 @@ app.get("/_ah/health", (req, res) => {
res.sendStatus(200)
})

app.listen(process.env.PORT, "0.0.0.0", () => console.log("App started"))
module.exports = { app }
3 changes: 3 additions & 0 deletions examples/hello-world/services/hello-container/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { app } = require("./app")

app.listen(process.env.PORT, "0.0.0.0", () => console.log("App started"))
Loading

0 comments on commit 8e4d6d2

Please sign in to comment.