Skip to content
Snippets Groups Projects
Commit c5077de5 authored by nilstes's avatar nilstes
Browse files

feilsok

parent 5b016ae8
No related branches found
No related tags found
No related merge requests found
......@@ -7,20 +7,8 @@ services:
# Configure test-database
variables:
MYSQL_DATABASE: db
MYSQL_ROOT_PASSWORD: password
# Create database tables
#connect:
# image: mysql
# script:
# - echo "SELECT 'OK';" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" < create_tables.sql
# Install node libraries
before_script:
- npm install
- apt-get update -q && apt-get install -qqy --no-install-recommends mysql-client
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" < create_tables.sql
MYSQL_ROOT_PASSWORD: secret
# Run JEST tests
test:
script:
......
var mysql = require("mysql");
var pool = mysql.createPool({
connectionLimit: 2,
host: "mysql",
user: "root",
password: "secret",
database: "db",
debug: false
});
test("query db", () => {
pool.getConnection((err, connection) => {
console.log("Connected to database");
if (err) {
console.log("Feil ved kobling til databasen");
res.json({ error: "feil ved ved oppkobling" });
} else {
connection.query(
"select navn, alder, adresse from person",
(err, rows) => {
connection.release();
if (err) {
console.log(err);
res.json({ error: "error querying" });
} else {
console.log("returning rows");
res.json(rows);
}
}
);
}
});
expect(sum(1, 2)).toBe(3);
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment