@@ -1144,9 +1144,8 @@ func TestList(t *testing.T) {
1144
1144
t .Logf ("%d: body: %s" , i , string (body ))
1145
1145
continue
1146
1146
}
1147
- // TODO: future, restore get links
1148
- if ! selfLinker .called {
1149
- t .Errorf ("%d: never set self link" , i )
1147
+ if utilfeature .DefaultFeatureGate .Enabled (features .RemoveSelfLink ) == selfLinker .called {
1148
+ t .Errorf ("%d: unexpected selfLinker.called: %v" , i , selfLinker .called )
1150
1149
}
1151
1150
if ! simpleStorage .namespacePresent {
1152
1151
t .Errorf ("%d: namespace not set" , i )
@@ -1279,9 +1278,8 @@ func TestListCompression(t *testing.T) {
1279
1278
t .Logf ("%d: body: %s" , i , string (body ))
1280
1279
continue
1281
1280
}
1282
- // TODO: future, restore get links
1283
- if ! selfLinker .called {
1284
- t .Errorf ("%d: never set self link" , i )
1281
+ if utilfeature .DefaultFeatureGate .Enabled (features .RemoveSelfLink ) == selfLinker .called {
1282
+ t .Errorf ("%d: unexpected selfLinker.called: %v" , i , selfLinker .called )
1285
1283
}
1286
1284
if ! simpleStorage .namespacePresent {
1287
1285
t .Errorf ("%d: namespace not set" , i )
@@ -1399,12 +1397,14 @@ func TestNonEmptyList(t *testing.T) {
1399
1397
if listOut .Items [0 ].Other != simpleStorage .list [0 ].Other {
1400
1398
t .Errorf ("Unexpected data: %#v, %s" , listOut .Items [0 ], string (body ))
1401
1399
}
1402
- if listOut .SelfLink != "/" + prefix + "/" + testGroupVersion .Group + "/" + testGroupVersion .Version + "/simple" {
1403
- t .Errorf ("unexpected list self link: %#v" , listOut )
1404
- }
1405
- expectedSelfLink := "/" + prefix + "/" + testGroupVersion .Group + "/" + testGroupVersion .Version + "/namespaces/other/simple/something"
1406
- if listOut .Items [0 ].ObjectMeta .SelfLink != expectedSelfLink {
1407
- t .Errorf ("Unexpected data: %#v, %s" , listOut .Items [0 ].ObjectMeta .SelfLink , expectedSelfLink )
1400
+ if ! utilfeature .DefaultFeatureGate .Enabled (features .RemoveSelfLink ) {
1401
+ if listOut .SelfLink != "/" + prefix + "/" + testGroupVersion .Group + "/" + testGroupVersion .Version + "/simple" {
1402
+ t .Errorf ("unexpected list self link: %#v" , listOut )
1403
+ }
1404
+ expectedSelfLink := "/" + prefix + "/" + testGroupVersion .Group + "/" + testGroupVersion .Version + "/namespaces/other/simple/something"
1405
+ if listOut .Items [0 ].ObjectMeta .SelfLink != expectedSelfLink {
1406
+ t .Errorf ("Unexpected data: %#v, %s" , listOut .Items [0 ].ObjectMeta .SelfLink , expectedSelfLink )
1407
+ }
1408
1408
}
1409
1409
}
1410
1410
@@ -1449,16 +1449,20 @@ func TestSelfLinkSkipsEmptyName(t *testing.T) {
1449
1449
if listOut .Items [0 ].Other != simpleStorage .list [0 ].Other {
1450
1450
t .Errorf ("Unexpected data: %#v, %s" , listOut .Items [0 ], string (body ))
1451
1451
}
1452
- if listOut .SelfLink != "/" + prefix + "/" + testGroupVersion .Group + "/" + testGroupVersion .Version + "/simple" {
1453
- t .Errorf ("unexpected list self link: %#v" , listOut )
1454
- }
1455
- expectedSelfLink := ""
1456
- if listOut .Items [0 ].ObjectMeta .SelfLink != expectedSelfLink {
1457
- t .Errorf ("Unexpected data: %#v, %s" , listOut .Items [0 ].ObjectMeta .SelfLink , expectedSelfLink )
1452
+ if ! utilfeature .DefaultFeatureGate .Enabled (features .RemoveSelfLink ) {
1453
+ if listOut .SelfLink != "/" + prefix + "/" + testGroupVersion .Group + "/" + testGroupVersion .Version + "/simple" {
1454
+ t .Errorf ("unexpected list self link: %#v" , listOut )
1455
+ }
1456
+ expectedSelfLink := ""
1457
+ if listOut .Items [0 ].ObjectMeta .SelfLink != expectedSelfLink {
1458
+ t .Errorf ("Unexpected data: %#v, %s" , listOut .Items [0 ].ObjectMeta .SelfLink , expectedSelfLink )
1459
+ }
1458
1460
}
1459
1461
}
1460
1462
1461
1463
func TestRootSelfLink (t * testing.T ) {
1464
+ defer featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , features .RemoveSelfLink , false )()
1465
+
1462
1466
storage := map [string ]rest.Storage {}
1463
1467
simpleStorage := GetWithOptionsRootRESTStorage {
1464
1468
SimpleTypedStorage : & SimpleTypedStorage {
@@ -1596,8 +1600,8 @@ func TestExport(t *testing.T) {
1596
1600
t .Errorf ("Expected: exported, saw: %s" , itemOut .Other )
1597
1601
}
1598
1602
1599
- if ! selfLinker .called {
1600
- t .Errorf ("Never set self link" )
1603
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
1604
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
1601
1605
}
1602
1606
}
1603
1607
@@ -1635,8 +1639,8 @@ func TestGet(t *testing.T) {
1635
1639
if itemOut .Name != simpleStorage .item .Name {
1636
1640
t .Errorf ("Unexpected data: %#v, expected %#v (%s)" , itemOut , simpleStorage .item , string (body ))
1637
1641
}
1638
- if ! selfLinker .called {
1639
- t .Errorf ("Never set self link" )
1642
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
1643
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
1640
1644
}
1641
1645
}
1642
1646
@@ -1715,6 +1719,7 @@ func BenchmarkGetNoCompression(b *testing.B) {
1715
1719
}
1716
1720
b .StopTimer ()
1717
1721
}
1722
+
1718
1723
func TestGetCompression (t * testing.T ) {
1719
1724
storage := map [string ]rest.Storage {}
1720
1725
simpleStorage := SimpleRESTStorage {
@@ -1781,8 +1786,8 @@ func TestGetCompression(t *testing.T) {
1781
1786
if itemOut .Name != simpleStorage .item .Name {
1782
1787
t .Errorf ("Unexpected data: %#v, expected %#v (%s)" , itemOut , simpleStorage .item , string (body ))
1783
1788
}
1784
- if ! selfLinker .called {
1785
- t .Errorf ("Never set self link" )
1789
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
1790
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
1786
1791
}
1787
1792
}
1788
1793
}
@@ -2762,8 +2767,8 @@ func TestGetAlternateSelfLink(t *testing.T) {
2762
2767
if itemOut .Name != simpleStorage .item .Name {
2763
2768
t .Errorf ("Unexpected data: %#v, expected %#v (%s)" , itemOut , simpleStorage .item , string (body ))
2764
2769
}
2765
- if ! selfLinker .called {
2766
- t .Errorf ("Never set self link" )
2770
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
2771
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
2767
2772
}
2768
2773
}
2769
2774
@@ -2800,8 +2805,8 @@ func TestGetNamespaceSelfLink(t *testing.T) {
2800
2805
if itemOut .Name != simpleStorage .item .Name {
2801
2806
t .Errorf ("Unexpected data: %#v, expected %#v (%s)" , itemOut , simpleStorage .item , string (body ))
2802
2807
}
2803
- if ! selfLinker .called {
2804
- t .Errorf ("Never set self link" )
2808
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
2809
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
2805
2810
}
2806
2811
}
2807
2812
@@ -3342,8 +3347,8 @@ func TestUpdate(t *testing.T) {
3342
3347
if simpleStorage .updated == nil || simpleStorage .updated .Name != item .Name {
3343
3348
t .Errorf ("Unexpected update value %#v, expected %#v." , simpleStorage .updated , item )
3344
3349
}
3345
- if ! selfLinker .called {
3346
- t .Errorf ("Never set self link" )
3350
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
3351
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
3347
3352
}
3348
3353
}
3349
3354
@@ -4010,8 +4015,8 @@ func TestCreate(t *testing.T) {
4010
4015
if response .StatusCode != http .StatusCreated {
4011
4016
t .Errorf ("Unexpected status: %d, Expected: %d, %#v" , response .StatusCode , http .StatusOK , response )
4012
4017
}
4013
- if ! selfLinker .called {
4014
- t .Errorf ("Never set self link" )
4018
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
4019
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
4015
4020
}
4016
4021
}
4017
4022
@@ -4080,8 +4085,8 @@ func TestCreateYAML(t *testing.T) {
4080
4085
if response .StatusCode != http .StatusCreated {
4081
4086
t .Errorf ("Unexpected status: %d, Expected: %d, %#v" , response .StatusCode , http .StatusOK , response )
4082
4087
}
4083
- if ! selfLinker .called {
4084
- t .Errorf ("Never set self link" )
4088
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
4089
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
4085
4090
}
4086
4091
}
4087
4092
@@ -4140,8 +4145,8 @@ func TestCreateInNamespace(t *testing.T) {
4140
4145
if response .StatusCode != http .StatusCreated {
4141
4146
t .Errorf ("Unexpected status: %d, Expected: %d, %#v" , response .StatusCode , http .StatusOK , response )
4142
4147
}
4143
- if ! selfLinker .called {
4144
- t .Errorf ("Never set self link" )
4148
+ if utilfeature . DefaultFeatureGate . Enabled ( features . RemoveSelfLink ) == selfLinker .called {
4149
+ t .Errorf ("unexpected selfLinker.called: %v" , selfLinker . called )
4145
4150
}
4146
4151
}
4147
4152
0 commit comments