This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The MIT License (MIT) | |
# | |
# Copyright (c) 2016 Damien Lespiau | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestMain(m *testing.M) { | |
// Parse the command line using the stdlib flag package so the flags | |
// defined in the testing package are populated. This include the | |
// -coverprofile flag. | |
flag.Parse() | |
// Strip command line arguments that were for the testing package and | |
// that are now handled. This will remove arguments that wouldn't be | |
// recognised when using a 3rd party command line parser like | |
// github.com/urfave/cli. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add is tested with a unit test | |
func add(a, b int) int { | |
return a + b | |
} | |
// sub is tested by running "calc sub 2 3". | |
func sub(a, b int) int { | |
return a - b | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestAdd(t *testing.T) { | |
tests := []struct { | |
a, b, expected int | |
}{ | |
{0, 0, 0}, | |
{1, 1, 2}, | |
{-2, 1, -1}, | |
{-1, -10, -11}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type dummyTestDeps func(pat, str string) (bool, error) | |
func (d dummyTestDeps) MatchString(pat, str string) (bool, error) { return false, nil } | |
func (d dummyTestDeps) StartCPUProfile(io.Writer) error { return nil } | |
func (d dummyTestDeps) StopCPUProfile() {} | |
func (d dummyTestDeps) WriteHeapProfile(io.Writer) error { return nil } | |
func (d dummyTestDeps) WriteProfileTo(string, io.Writer, int) error { return nil } | |
func (f dummyTestDeps) ImportPath() string { return "" } | |
// FlushProfiles flushes test profiles to disk. It works by build and executing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestConsistentAllRequestsAnswered(t *testing.T) { | |
t.Parallel() | |
test := kube.NewTest(t).Setup() | |
defer test.Close() | |
// Create a deploymenent from a manifest file and wait for all replicas to be ready. | |
service := test.CreateDeploymentFromFile(test.Namespace, "service-deploy.yaml") | |
test.WaitForDeploymentReady(service, 1*time.Minute) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const template = context => ({ | |
key: 'value', | |
count: context.count, | |
}); | |
export default [ | |
{ path: 'foo.yaml', value: template({ count: 42 }) }, | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ jk run template.js | |
key: 'value' | |
count: 42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_ssh_url() { | |
echo $1 | sed -e 's#^https://github.com/#git@github.com:#' | |
} | |
git_http_url() { | |
echo $1 | sed -e 's#^git@github.com:#https://github.com/#' | |
} |