package storage

import (
	"testing"

	"cloud.o-forge.io/core/oc-lib/models/resource_model"
	"cloud.o-forge.io/core/oc-lib/models/utils"

	"github.com/stretchr/testify/assert"
)

func TestStoreOneStorage(t *testing.T) {
	s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
		AbstractResource: resource_model.AbstractResource{
			AbstractObject: utils.AbstractObject{Name: "testData"},
			Description:    "Lorem Ipsum",
			Logo:           "azerty.com",
			Owner:          "toto",
			OwnerLogo:      "totoLogo",
			SourceUrl:      "azerty.fr",
		},
	}

	sma := New()
	id, _, _ := sma.StoreOne(&s)

	assert.NotEmpty(t, id)
}

func TestLoadOneStorage(t *testing.T) {
	s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
		AbstractResource: resource_model.AbstractResource{
			AbstractObject: utils.AbstractObject{Name: "testData"},
			Description:    "Lorem Ipsum",
			Logo:           "azerty.com",
			Owner:          "toto",
			OwnerLogo:      "totoLogo",
			SourceUrl:      "azerty.fr",
		},
	}

	sma := New()
	new_s, _, _ := sma.StoreOne(&s)

	assert.Equal(t, s, new_s)
}
