Skip to content

Commit

Permalink
test(patch): add integration test for .patch (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
celiawaggoner authored and Silas Boyd-Wickizer committed Jun 10, 2019
1 parent eb83d4a commit 92d9729
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test-integration/patch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect
const fs = require('fs')
const yaml = require('js-yaml')

const env = require('./env')

describe('test-integration/patch', () => {
let namespace = null
beforeEach(async () => {
namespace = await env.setupNamespace()
})
afterEach(async () => {
await env.tearDownNamespace(namespace)
})

it('patches a pod', async () => {
let pod
const manifest = yaml.safeLoad(fs.readFileSync('./test-integration/busybox-pod.yaml'))
const name = manifest.metadata.name
const client = await env.getClient()
await client.api.v1.namespaces(namespace).pods.post({ body: manifest })

pod = await client.api.v1.namespaces(namespace).pods(name).get()
expect(pod.body.metadata.annotations).to.equal(undefined)

await client.api.v1.namespaces(namespace).pods(name).patch({
body: {
metadata: {
annotations: {
'patch-test0': process.pid.toString()
}
}
}
})

pod = await client.api.v1.namespaces(namespace).pods(name).get()
expect(pod.body.metadata.annotations['patch-test0']).equals(process.pid.toString())
})
})

0 comments on commit 92d9729

Please sign in to comment.