@@ -1556,17 +1556,18 @@ func TestAPI(t *testing.T) {
1556
1556
}
1557
1557
1558
1558
tests := []struct {
1559
- name string
1560
- customization []agentcontainers.CoderCustomization
1561
- afterCreate func (t * testing.T , subAgent agentcontainers.SubAgent )
1559
+ name string
1560
+ customization agentcontainers.CoderCustomization
1561
+ mergedCustomizations []agentcontainers.CoderCustomization
1562
+ afterCreate func (t * testing.T , subAgent agentcontainers.SubAgent )
1562
1563
}{
1563
1564
{
1564
- name : "WithoutCustomization" ,
1565
- customization : nil ,
1565
+ name : "WithoutCustomization" ,
1566
+ mergedCustomizations : nil ,
1566
1567
},
1567
1568
{
1568
- name : "WithDefaultDisplayApps" ,
1569
- customization : []agentcontainers.CoderCustomization {},
1569
+ name : "WithDefaultDisplayApps" ,
1570
+ mergedCustomizations : []agentcontainers.CoderCustomization {},
1570
1571
afterCreate : func (t * testing.T , subAgent agentcontainers.SubAgent ) {
1571
1572
require .Len (t , subAgent .DisplayApps , 4 )
1572
1573
assert .Contains (t , subAgent .DisplayApps , codersdk .DisplayAppVSCodeDesktop )
@@ -1577,7 +1578,7 @@ func TestAPI(t *testing.T) {
1577
1578
},
1578
1579
{
1579
1580
name : "WithAllDisplayApps" ,
1580
- customization : []agentcontainers.CoderCustomization {
1581
+ mergedCustomizations : []agentcontainers.CoderCustomization {
1581
1582
{
1582
1583
DisplayApps : map [codersdk.DisplayApp ]bool {
1583
1584
codersdk .DisplayAppSSH : true ,
@@ -1599,7 +1600,7 @@ func TestAPI(t *testing.T) {
1599
1600
},
1600
1601
{
1601
1602
name : "WithSomeDisplayAppsDisabled" ,
1602
- customization : []agentcontainers.CoderCustomization {
1603
+ mergedCustomizations : []agentcontainers.CoderCustomization {
1603
1604
{
1604
1605
DisplayApps : map [codersdk.DisplayApp ]bool {
1605
1606
codersdk .DisplayAppSSH : false ,
@@ -1631,7 +1632,7 @@ func TestAPI(t *testing.T) {
1631
1632
},
1632
1633
{
1633
1634
name : "WithApps" ,
1634
- customization : []agentcontainers.CoderCustomization {
1635
+ mergedCustomizations : []agentcontainers.CoderCustomization {
1635
1636
{
1636
1637
Apps : []agentcontainers.SubAgentApp {
1637
1638
{
@@ -1699,7 +1700,7 @@ func TestAPI(t *testing.T) {
1699
1700
},
1700
1701
{
1701
1702
name : "AppDeduplication" ,
1702
- customization : []agentcontainers.CoderCustomization {
1703
+ mergedCustomizations : []agentcontainers.CoderCustomization {
1703
1704
{
1704
1705
Apps : []agentcontainers.SubAgentApp {
1705
1706
{
@@ -1739,6 +1740,52 @@ func TestAPI(t *testing.T) {
1739
1740
assert .Equal (t , int32 (2 ), subAgent .Apps [1 ].Order )
1740
1741
},
1741
1742
},
1743
+ {
1744
+ name : "Name" ,
1745
+ customization : agentcontainers.CoderCustomization {
1746
+ Name : "this-name" ,
1747
+ },
1748
+ mergedCustomizations : []agentcontainers.CoderCustomization {
1749
+ {
1750
+ Name : "not-this-name" ,
1751
+ },
1752
+ {
1753
+ Name : "or-this-name" ,
1754
+ },
1755
+ },
1756
+ afterCreate : func (t * testing.T , subAgent agentcontainers.SubAgent ) {
1757
+ require .Equal (t , "this-name" , subAgent .Name )
1758
+ },
1759
+ },
1760
+ {
1761
+ name : "NameIsOnlyUsedFromRoot" ,
1762
+ mergedCustomizations : []agentcontainers.CoderCustomization {
1763
+ {
1764
+ Name : "custom-name" ,
1765
+ },
1766
+ },
1767
+ afterCreate : func (t * testing.T , subAgent agentcontainers.SubAgent ) {
1768
+ require .NotEqual (t , "custom-name" , subAgent .Name )
1769
+ },
1770
+ },
1771
+ {
1772
+ name : "EmptyNameIsIgnored" ,
1773
+ customization : agentcontainers.CoderCustomization {
1774
+ Name : "" ,
1775
+ },
1776
+ afterCreate : func (t * testing.T , subAgent agentcontainers.SubAgent ) {
1777
+ require .NotEmpty (t , subAgent .Name )
1778
+ },
1779
+ },
1780
+ {
1781
+ name : "InvalidNameIsIgnored" ,
1782
+ customization : agentcontainers.CoderCustomization {
1783
+ Name : "This--Is_An_Invalid--Name" ,
1784
+ },
1785
+ afterCreate : func (t * testing.T , subAgent agentcontainers.SubAgent ) {
1786
+ require .NotEqual (t , "This--Is_An_Invalid--Name" , subAgent .Name )
1787
+ },
1788
+ },
1742
1789
}
1743
1790
1744
1791
for _ , tt := range tests {
@@ -1756,11 +1803,16 @@ func TestAPI(t *testing.T) {
1756
1803
}
1757
1804
fDCCLI = & fakeDevcontainerCLI {
1758
1805
readConfig : agentcontainers.DevcontainerConfig {
1759
- MergedConfiguration : agentcontainers.DevcontainerConfiguration {
1806
+ Configuration : agentcontainers.DevcontainerConfiguration {
1760
1807
Customizations : agentcontainers.DevcontainerCustomizations {
1761
1808
Coder : tt .customization ,
1762
1809
},
1763
1810
},
1811
+ MergedConfiguration : agentcontainers.DevcontainerMergedConfiguration {
1812
+ Customizations : agentcontainers.DevcontainerMergedCustomizations {
1813
+ Coder : tt .mergedCustomizations ,
1814
+ },
1815
+ },
1764
1816
},
1765
1817
execErrC : make (chan func (cmd string , args ... string ) error , 1 ),
1766
1818
}
@@ -1825,7 +1877,6 @@ func TestAPI(t *testing.T) {
1825
1877
1826
1878
// Then: We expected it to succeed
1827
1879
require .Len (t , fSAC .created , 1 )
1828
- assert .Equal (t , testContainer .FriendlyName , fSAC .created [0 ].Name )
1829
1880
1830
1881
if tt .afterCreate != nil {
1831
1882
tt .afterCreate (t , fSAC .created [0 ])
0 commit comments