func (e *e2e) DeleteUpdateOperations(ctx context.Context) func(*testing.T) {
	if err := ctx.Err(); err != nil {
		return func(t *testing.T) { t.Skip(err) }
	}
	return func(t *testing.T) {
		defer e.failed(t)

		const (
			opExists    = `SELECT EXISTS(SELECT 1 FROM update_operation WHERE ref = $1::uuid);`
			assocExists = `SELECT EXISTS(SELECT 1 FROM uo_vuln JOIN update_operation uo ON (uo_vuln.uo = uo.id) WHERE uo.ref = $1::uuid);`
		)
		var exists bool
		for _, op := range e.updateOps {
			err := e.s.DeleteUpdateOperations(ctx, op.Ref)
			if err != nil {
				t.Fatalf("failed to get delete UpdateOperation: %v", err)
			}

			// Check that the update_operation is removed from the table.
			if err := e.pool.QueryRow(ctx, opExists, op.Ref).Scan(&exists); err != nil {
				t.Errorf("query failed: %v", err)
			}
			t.Logf("operation %v exists: %v", op.Ref, exists)
			if exists {
				t.Error()
			}

			// This really shouldn't happen because of the foreign constraint.
			if err := e.pool.QueryRow(ctx, assocExists, op.Ref).Scan(&exists); err != nil {
				t.Errorf("query failed: %v", err)
			}
			t.Logf("operation %v exists: %v", op.Ref, exists)
			if exists {
				t.Error()
			}
		}
		t.Log("ok")
	}
}
// DeleteUpdateOperations performs a deletion of all UpdateOperations used in
// the test and confirms both the UpdateOperation and vulnerabilities are
// removed from the vulnstore.
DeleteUpdateOperations performs a deletion of all UpdateOperations used in
the test and confirms both the UpdateOperation and vulnerabilities are
removed from the vulnstore.
// DeleteUpdateOperations performs a deletion of all UpdateOperations used in // the test and confirms both the UpdateOperation and vulnerabilities are // removed from the vulnstore .
func (e *e2e) DeleteUpdateOperations(ctx context.Context) func(*testing.T) {
	if err := ctx.Err(); err != nil {
		return func(t *testing.T) { t.Skip(err) }
	}
	return func(t *testing.T) {
		defer e.failed(t)
		const (
			opExists    = `SELECT EXISTS(SELECT 1 FROM update_operation WHERE ref = $1::uuid);`
			assocExists = `SELECT EXISTS(SELECT 1 FROM uo_vuln JOIN update_operation uo ON (uo_vuln.uo = uo.id) WHERE uo.ref = $1::uuid);`
		)
		var exists bool
		for _, op := range e.updateOps {
			err := e.s.DeleteUpdateOperations(ctx, op.Ref)
			if err != nil {
				t.Fatalf("failed to get delete UpdateOperation: %v", err)
			}
			if err := e.pool.QueryRow(ctx, opExists, op.Ref).Scan(&exists); err != nil {
				t.Errorf("query failed: %v", err)
			}
			t.Logf("operation %v exists: %v", op.Ref, exists)
			if exists {
				t.Error()
			}
			if err := e.pool.QueryRow(ctx, assocExists, op.Ref).Scan(&exists); err != nil {
				t.Errorf("query failed: %v", err)
			}
			t.Logf("operation %v exists: %v", op.Ref, exists)
			if exists {
				t.Error()
			}
		}
		t.Log("ok")
	}
}
func ( e * e2e ) DeleteUpdateOperations ( ctx context . Context ) func ( * testing . T ) { if err := ctx . Err ( ) ; err != nil { return func ( t * testing . T ) { t . Skip ( err ) } } return func ( t * testing . T ) { defer e . failed ( t ) const ( opExists = `SELECT EXISTS(SELECT 1 FROM update_operation WHERE ref = $1::uuid);` assocExists = `SELECT EXISTS(SELECT 1 FROM uo_vuln JOIN update_operation uo ON (uo_vuln.uo = uo.id) WHERE uo.ref = $1::uuid);` ) var exists bool for _ , op := range e . updateOps { err := e . s . DeleteUpdateOperations ( ctx , op . Ref ) if err != nil { t . Fatalf ( " " , err ) } if err := e . pool . QueryRow ( ctx , opExists , op . Ref ) . Scan ( & exists ) ; err != nil { t . Errorf ( " " , err ) } t . Logf ( " " , op . Ref , exists ) if exists { t . Error ( ) } if err := e . pool . QueryRow ( ctx , assocExists , op . Ref ) . Scan ( & exists ) ; err != nil { t . Errorf ( " " , err ) } t . Logf ( " " , op . Ref , exists ) if exists { t . Error ( ) } } t . Log ( " " ) } }
DeleteUpdateOperations performs a deletion of all UpdateOperations used in
the test and confirms both the UpdateOperation and vulnerabilities are
removed from the vulnstore.
DeleteUpdateOperations performs a deletion of all UpdateOperations used in the test and confirms both the UpdateOperation and vulnerabilities are removed from the vulnstore .
// Check that the update_operation is removed from the table. // This really shouldn't happen because of the foreign constraint.