Repository: threefoldtech/zos
Pull request #513 (2020-02-04 13:34:09)

gedis: send workload id in Deleted method

codecov[bot]: # [Codecov](https://codecov.io/gh/threefoldtech/zos/pull/513?src=pr&el=h1) Report
> Merging [#513](https://codecov.io/gh/threefoldtech/zos/pull/513?src=pr&el=desc) into [master](https://codecov.io/gh/threefoldtech/zos/commit/7ac6339a666be6f8751cba6e2c2cd550c6d755cb?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `0%`.

[![Impacted file tree graph](https://codecov.io/gh/threefoldtech/zos/pull/513/graphs/tree.svg?width=650&token=f7Vmq1OAEm&height=150&src=pr)](https://codecov.io/gh/threefoldtech/zos/pull/513?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
- Coverage   36.03%   36.01%   -0.02%     
==========================================
  Files          74       74              
  Lines        5087     5089       +2     
==========================================
  Hits         1833     1833              
- Misses       2991     2993       +2     
  Partials      263      263
```


| [Impacted Files](https://codecov.io/gh/threefoldtech/zos/pull/513?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../provision/tfgrid\_reservation\_statsaggregator\_1.go](https://codecov.io/gh/threefoldtech/zos/pull/513/diff?src=pr&el=tree#diff-cGtnL2dlZGlzL3R5cGVzL3Byb3Zpc2lvbi90ZmdyaWRfcmVzZXJ2YXRpb25fc3RhdHNhZ2dyZWdhdG9yXzEuZ28=) | `0% <0%> (ø)` | :arrow_up: |
| [pkg/gedis/commands\_provision.go](https://codecov.io/gh/threefoldtech/zos/pull/513/diff?src=pr&el=tree#diff-cGtnL2dlZGlzL2NvbW1hbmRzX3Byb3Zpc2lvbi5nbw==) | `38.91% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/threefoldtech/zos/pull/513?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/threefoldtech/zos/pull/513?src=pr&el=footer). Last update [7ac6339...fbea4bb](https://codecov.io/gh/threefoldtech/zos/pull/513?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/pkg/gedis/commands_provision.go b/pkg/gedis/commands_provision.go
index 155e1385..ec9f9b6b 100644
--- a/pkg/gedis/commands_provision.go
+++ b/pkg/gedis/commands_provision.go
@@ -179,7 +179,7 @@ func (g *Gedis) Feedback(id string, r *provision.Result) error {
 
 // Deleted implements provision.Feedbacker
 func (g *Gedis) Deleted(id string) error {
-	_, err := g.Send("tfgrid.workloads.workload_manager", "workload_deleted", Args{})
+	_, err := g.Send("tfgrid.workloads.workload_manager", "workload_deleted", Args{"workload_id": id})
 	return err
 }
 
diff --git a/pkg/gedis/types/provision/tfgrid_reservation_statsaggregator_1.go b/pkg/gedis/types/provision/tfgrid_reservation_statsaggregator_1.go
index 96dddc24..18d9262d 100644
--- a/pkg/gedis/types/provision/tfgrid_reservation_statsaggregator_1.go
+++ b/pkg/gedis/types/provision/tfgrid_reservation_statsaggregator_1.go
@@ -55,6 +55,7 @@ type TfgridReservationResult1StateEnum uint8
 const (
 	TfgridReservationResult1StateError TfgridReservationResult1StateEnum = iota
 	TfgridReservationResult1StateOk
+	TfgridReservationResult1StateDeleted
 )
 
 func (e TfgridReservationResult1StateEnum) String() string {
@@ -63,6 +64,8 @@ func (e TfgridReservationResult1StateEnum) String() string {
 		return "error"
 	case TfgridReservationResult1StateOk:
 		return "ok"
+	case TfgridReservationResult1StateDeleted:
+		return "deleted"
 	}
 	return "UNKNOWN"
 }


Test patch:
diff --git a/pkg/gedis/commands_provision_test.go b/pkg/gedis/commands_provision_test.go
index 12780d47..95444c3b 100644
--- a/pkg/gedis/commands_provision_test.go
+++ b/pkg/gedis/commands_provision_test.go
@@ -211,3 +211,45 @@ func TestProvisionReserve(t *testing.T) {
 	require.Equal("10", result)
 	conn.AssertCalled(t, "Close")
 }
+
+func TestProvisionDeleted(t *testing.T) {
+	require := require.New(t)
+	pool, conn := getTestPool()
+	gedis := Gedis{
+		pool: pool,
+	}
+
+	id := "101"
+	args := Args{
+		"workload_id": id,
+	}
+
+	conn.On("Do", "tfgrid.workloads.workload_manager.workload_deleted", mustMarshal(t, args)).
+		Return(nil, nil)
+
+	err := gedis.Deleted(id)
+
+	require.NoError(err)
+	conn.AssertCalled(t, "Close")
+}
+
+func TestProvisionDelete(t *testing.T) {
+	require := require.New(t)
+	pool, conn := getTestPool()
+	gedis := Gedis{
+		pool: pool,
+	}
+
+	id := "101"
+	args := Args{
+		"reservation_id": id,
+	}
+
+	conn.On("Do", "tfgrid.workloads.workload_manager.sign_delete", mustMarshal(t, args)).
+		Return(nil, nil)
+
+	err := gedis.Delete(id)
+
+	require.NoError(err)
+	conn.AssertCalled(t, "Close")
+}