github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/docker/test_state.go (about)

     1  package docker
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/docker/docker/api/types"
     7  )
     8  
     9  // Helper functions for generating container states.
    10  
    11  func NewCreatedContainerState() types.ContainerState {
    12  	return types.ContainerState{
    13  		Status:     "created",
    14  		StartedAt:  ZeroTime,
    15  		FinishedAt: ZeroTime,
    16  	}
    17  }
    18  
    19  func NewRunningContainerState() types.ContainerState {
    20  	return types.ContainerState{
    21  		Running:    true,
    22  		StartedAt:  time.Now().Format(time.RFC3339Nano),
    23  		FinishedAt: ZeroTime,
    24  	}
    25  }
    26  
    27  func NewExitSuccessContainerState() types.ContainerState {
    28  	return types.ContainerState{
    29  		StartedAt:  time.Now().Format(time.RFC3339Nano),
    30  		FinishedAt: time.Now().Format(time.RFC3339Nano),
    31  		ExitCode:   0,
    32  	}
    33  }
    34  
    35  func NewExitErrorContainerState() types.ContainerState {
    36  	return types.ContainerState{
    37  		StartedAt:  time.Now().Format(time.RFC3339Nano),
    38  		FinishedAt: time.Now().Format(time.RFC3339Nano),
    39  		ExitCode:   1,
    40  	}
    41  }