Skip to content

Instantly share code, notes, and snippets.

View patoi's full-sized avatar
👀
...

István Pató patoi

👀
...
View GitHub Profile
echo "Type your email, followed by [ENTER]:"
read email
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && git config user.email $email" \;
@patoi
patoi / start_testing_java8_today.asciidoc
Last active February 28, 2018 11:44 — forked from aslakknutsen/start_testing_java8_today.asciidoc
Example of how to use both JDK 7 and JDK 8 in one build.

JDK 8 Released

Most of us won’t be able to use/deploy JDK 8 in production for a looong time. But that shouldn’t stop us from using it, right?

It should be possible to sneak in JDK 8 in the back way, the same way we snuck in Groovy and other libraries we wanted to use.

The Test Suite to the rescue

The Maven compiler plugin run in two separate lifecycles, compile and testCompile. Those can be configured separately.

@patoi
patoi / code.js
Last active April 3, 2018 09:10
Testing async/await
async function testFunction (isOK) {
if (isOK === true) {
return 'OK'
} else {
throw new Error('not OK')
}
}
it('is OK - not bad', async () => {
let result = await testFunction(true)
expect(result).to.be.equal('OK')
// flawed test throws an error, but it is not a test error (AssertionError)
})
it('is not OK - bad!', async () => {
try {
let result = await testFunction(false)
// flawed tests __pass__ instead of throws an error!
} catch (err) {
expect(err.message).to.be.equal('not OK')
}
})
it('is not OK - not bad, but it could be better', async () => {
try {
let result = await testFunction(false)
expect.fail()
// flawed test throws an ugly error:
} catch (err) {
// ...'AssertionError: expected 'expect.fail()' to equal 'not OK''
expect(err.message).to.be.equal('not OK')
}
})
it('is not OK - better way', async function() {
let result, error
try {
result = await testFunction(false)
} catch (err) {
error = err
} finally {
expect(result).to.be.undefined() // guard: handling code flaw
expect(error.message).to.be.equal('not OK')
}
it('is OK - better way', async function() {
let result, error
try {
result = await testFunction(true)
} catch (err) {
error = err
} finally {
expect(error).to.be.undefined() // guard: handling code flaw
expect(result).to.be.equal('OK')
}
it('your test', async function() {
let args = ... // your test data
let result, error // variables: test and guard in the finally block
try {
result = await testFunction(args)
} catch (err) {
error = err
} finally {
FROM node:8-alpine
# the client version we will download from bumpx repo
ENV CLIENT_FILENAME instantclient-basic-linux.x64-12.1.0.1.0.zip
# work in this directory
WORKDIR /opt/oracle/lib
# take advantage of this repo to easily download the client (use it at your own risk)
ADD https://github.com/bumpx/oracle-instantclient/raw/master/${CLIENT_FILENAME} .