Path: blob/main/components/docker-up/dockerd/args_test.go
2498 views
// Copyright (c) 2025 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package dockerd56import (7"reflect"8"sort"9"testing"1011"github.com/sirupsen/logrus"12)1314func TestMapUserArgs(t *testing.T) {15tests := []struct {16name string17input map[string]interface{}18expected []string19wantErr bool20}{21{22name: "empty input",23input: map[string]interface{}{},24expected: []string{},25wantErr: false,26},27{28name: "tls and proxy settings",29input: map[string]interface{}{30"proxies": map[string]interface{}{31"http-proxy": "localhost:38080",32"https-proxy": "localhost:38081",33},34},35expected: []string{36"--http-proxy=localhost:38080",37"--https-proxy=localhost:38081",38},39wantErr: false,40},41}4243for _, tt := range tests {44t.Run(tt.name, func(t *testing.T) {45log := logrus.New().WithField("test", t.Name())46got, err := mapUserArgs(log, tt.input)47if (err != nil) != tt.wantErr {48t.Errorf("mapUserArgs() error = %v, wantErr %v", err, tt.wantErr)49return50}51if !tt.wantErr {52sort.Strings(got)53sort.Strings(tt.expected)54// Sort both slices to ensure consistent comparison55if !reflect.DeepEqual(got, tt.expected) {56t.Errorf("mapUserArgs() = %v, want %v", got, tt.expected)57}58}59})60}61}626364