Skip to content

Instantly share code, notes, and snippets.

Damien Lespiau dlespiau

Block or report user

Report or block dlespiau

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View foo.sh
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/#'
}
View output
$ jk run template.js
key: 'value'
count: 42
View template.js
const template = context => ({
key: 'value',
count: context.count,
});
export default [
{ path: 'foo.yaml', value: template({ count: 42 }) },
]);
@dlespiau
dlespiau / basic_test.go
Last active Jun 12, 2018
Sampe kube-harness test
View basic_test.go
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)
@dlespiau
dlespiau / main_test.go
Last active May 29, 2017
calc - unit-tests
View main_test.go
func TestAdd(t *testing.T) {
tests := []struct {
a, b, expected int
}{
{0, 0, 0},
{1, 1, 2},
{-2, 1, -1},
{-1, -10, -11},
}
@dlespiau
dlespiau / main.go
Created May 29, 2017
calc - the awesome calculator
View main.go
// 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
}
@dlespiau
dlespiau / flush_profiles.go
Last active May 31, 2017
Flush Profiles to disk
View flush_profiles.go
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
@dlespiau
dlespiau / main_test.go
Last active May 28, 2017
Building coverage-instrumented programs with Go take 1
View main_test.go
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.
@dlespiau
dlespiau / test_db.py
Created May 3, 2016
Testing for pending migrations in Django
View test_db.py
# 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:
You can’t perform that action at this time.