blob: 18d05a9c3400dc5c9ae955140bfaf90013fbe705 [file] [log] [blame]
// Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package main
import (
func TestMergeEnvValues(t *testing.T) {
testData := []struct {
values []string
updates []string
result []string
{[]string{}, []string{}, []string{}},
{[]string{"A=1"}, []string{}, []string{"A=1"}},
{[]string{"A=1=2=3"}, []string{}, []string{"A=1=2=3"}},
{[]string{}, []string{"A=1"}, []string{"A=1"}},
{[]string{}, []string{"A=1=2=3"}, []string{"A=1=2=3"}},
{[]string{"A=1"}, []string{"A=2"}, []string{"A=2"}},
{[]string{"A="}, []string{}, []string{"A="}},
{[]string{"A="}, []string{"A=2"}, []string{"A=2"}},
{[]string{"A=1"}, []string{"A="}, []string{}},
{[]string{}, []string{"A=1", "A="}, []string{}},
{[]string{}, []string{"A=1", "A=", "A=2"}, []string{"A=2"}},
{[]string{"A=1", "B=2"}, []string{"C=3", "D=4"}, []string{"A=1", "B=2", "C=3", "D=4"}},
for _, tt := range testData {
result := mergeEnvValues(tt.values, tt.updates)
if !reflect.DeepEqual(tt.result, result) {
t.Errorf("unexpected result: %s", result)