All Projects â†’ testcontainers â†’ Testcontainers Go

testcontainers / Testcontainers Go

Licence: mit
Testcontainers is a Golang library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Testcontainers Go

Puppeteer Api Zh cn
📖 Puppeteer中文文档(官方指定的中文文档)
Stars: ✭ 697 (-14.37%)
Mutual labels:  automation
Repeat
Cross-platform mouse/keyboard record/replay and automation hotkeys/macros creation, and more advanced automation features.
Stars: ✭ 763 (-6.27%)
Mutual labels:  automation
Archisteamfarm
C# application with primary purpose of idling Steam cards from multiple accounts simultaneously.
Stars: ✭ 7,219 (+786.86%)
Mutual labels:  automation
Debotnet
🔥🚀 Debotnet is a tiny portable tool for controlling Windows 10's many privacy-related settings and keep your personal data private.
Stars: ✭ 707 (-13.14%)
Mutual labels:  automation
Prefect
The easiest way to automate your data
Stars: ✭ 7,956 (+877.4%)
Mutual labels:  automation
Just Api
💥 Test REST, GraphQL APIs
Stars: ✭ 768 (-5.65%)
Mutual labels:  automation
old vespene
DISCONTINUED: a frozen fork will exist forever at mpdehaan/vespene
Stars: ✭ 672 (-17.44%)
Mutual labels:  automation
Webdriverio
Next-gen browser and mobile automation test framework for Node.js
Stars: ✭ 7,214 (+786.24%)
Mutual labels:  automation
Ansible Best Practises
A project structure that outlines some best practises of how to use ansible
Stars: ✭ 735 (-9.71%)
Mutual labels:  automation
Webhook
webhook is a lightweight incoming webhook server to run shell commands
Stars: ✭ 7,201 (+784.64%)
Mutual labels:  automation
Diun
Receive notifications when an image is updated on a Docker registry
Stars: ✭ 704 (-13.51%)
Mutual labels:  automation
Leasot
Parse and output TODOs and FIXMEs from comments in your files
Stars: ✭ 729 (-10.44%)
Mutual labels:  automation
Dumpsterfire
"Security Incidents In A Box!" A modular, menu-driven, cross-platform tool for building customized, time-delayed, distributed security events. Easily create custom event chains for Blue- & Red Team drills and sensor / alert mapping. Red Teams can create decoy incidents, distractions, and lures to support and scale their operations. Build event sequences ("narratives") to simulate realistic scenarios and generate corresponding network and filesystem artifacts.
Stars: ✭ 775 (-4.79%)
Mutual labels:  automation
Vssh
Go Library to Execute Commands Over SSH at Scale
Stars: ✭ 707 (-13.14%)
Mutual labels:  automation
Babushka
Test-driven sysadmin.
Stars: ✭ 794 (-2.46%)
Mutual labels:  automation
Robotframework
Generic automation framework for acceptance testing and RPA
Stars: ✭ 6,534 (+702.7%)
Mutual labels:  automation
Appiumtestdistribution
A tool for running android and iOS appium tests in parallel across devices... U like it STAR it !
Stars: ✭ 764 (-6.14%)
Mutual labels:  automation
Puloversmacrocreator
Automation Utility - Recorder & Script Generator
Stars: ✭ 803 (-1.35%)
Mutual labels:  automation
Schemats
Generate typescript interface definitions from SQL database schema
Stars: ✭ 799 (-1.84%)
Mutual labels:  automation
Cmsscan
CMS Scanner: Scan Wordpress, Drupal, Joomla, vBulletin websites for Security issues
Stars: ✭ 775 (-4.79%)
Mutual labels:  automation

Main pipeline Go Report Card GoDoc Reference

When I was working on a Zipkin PR I discovered a nice Java library called Testcontainers.

It provides an easy and clean API over the go docker sdk to run, terminate and connect to containers in your tests.

I found myself comfortable programmatically writing the containers I need to run an integration/smoke tests. So I started porting this library in Go.

This is an example:

package main

import (
	"context"
	"fmt"
	"net/http"
	"testing"

	"github.com/testcontainers/testcontainers-go"
	"github.com/testcontainers/testcontainers-go/wait"
)

func TestNginxLatestReturn(t *testing.T) {
	ctx := context.Background()
	req := testcontainers.ContainerRequest{
		Image:        "nginx",
		ExposedPorts: []string{"80/tcp"},
		WaitingFor:   wait.ForHTTP("/"),
	}
	nginxC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
		ContainerRequest: req,
		Started:          true,
	})
	if err != nil {
		t.Error(err)
	}
	defer nginxC.Terminate(ctx)
	ip, err := nginxC.Host(ctx)
	if err != nil {
		t.Error(err)
	}
	port, err := nginxC.MappedPort(ctx, "80")
	if err != nil {
		t.Error(err)
	}
	resp, err := http.Get(fmt.Sprintf("http://%s:%s", ip, port.Port()))
	if resp.StatusCode != http.StatusOK {
		t.Errorf("Expected status code %d. Got %d.", http.StatusOK, resp.StatusCode)
	}
}

This is a simple example, you can create one container in my case using the nginx image. You can get its IP ip, err := nginxC.GetContainerIpAddress(ctx) and you can use it to make a GET: resp, err := http.Get(fmt.Sprintf("http://%s", ip))

To clean your environment you can defer the container termination defer nginxC.Terminate(ctx, t). t is *testing.T and it is used to notify is the defer failed marking the test as failed.

Documentation

The documentation lives in ./docs and it is rendered at golang.testcontainers.org.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].