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
package org.example | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.ReceiveChannel | |
import kotlinx.coroutines.flow.MutableSharedFlow | |
import kotlinx.coroutines.selects.onTimeout | |
import kotlinx.coroutines.selects.select | |
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
package org.example | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.ReceiveChannel | |
import kotlinx.coroutines.flow.MutableSharedFlow | |
import kotlinx.coroutines.selects.onTimeout | |
import kotlinx.coroutines.selects.select | |
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
package com.betclic.poker.gameserver.domain | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.flow.MutableSharedFlow | |
import kotlinx.coroutines.selects.onTimeout | |
import kotlinx.coroutines.selects.select | |
sealed interface Outcome { | |
data class Ok(val result: String) : Outcome |
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) { | |
var code = 1 | |
defer func() { os.Exit(code) }() | |
ctx := context.Background() | |
mongoContainer, err := setup(ctx, mongoDB) | |
if err != nil { | |
log.Printf("Unexpected error, fallback to mem repository implementations.\nerror: %s.\n", err) | |
allGames = mem.NewAllGames() | |
} else { |
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 setup(ctx context.Context, image image) (*container, error) { | |
cont, uri, err := prepareContainer(ctx, image) | |
if err != nil { | |
return nil, err | |
} | |
return &container{Container: cont, URI: uri}, nil | |
} |
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 prepareContainer(ctx context.Context, image image) (testcontainers.Container, string, error) { | |
req := testcontainers.ContainerRequest{ | |
Image: image.name, | |
ExposedPorts: []string{image.port + "/tcp"}, | |
WaitingFor: wait.ForListeningPort(nat.Port(image.port)), | |
} | |
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ | |
ContainerRequest: req, | |
Started: true, |
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 image struct { | |
name string | |
port string | |
} | |
var ( | |
allGames domain.AllGames | |
mongoDB = image{ | |
name: "mongo:5.0.8", |
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) { | |
log.Println("before all package tests") | |
exitCode := m.Run() | |
log.Println("after all package tests") | |
os.Exit(exitCode) | |
} |
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 Test_Add(t *testing.T) { | |
gameId := domain.GameId(uuid.NewString()) | |
allGames.Add(&domain.Game{ | |
Id: gameId, | |
Title: "Assassin's Creed Valhalla", | |
PEGI: domain.Eighteen, | |
}) |
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
package domain | |
type PEGI int | |
type GameId string | |
const ( | |
Three PEGI = iota | |
Seven | |
Twelve | |
Sixteen |
NewerOlder