<commit_before>package scp_test

import (
	"github.com/stretchr/testify/assert"
	"testing"

	"github.com/viant/toolbox/storage/scp"
	"io/ioutil"
	"os"
	"path"
	"strings"
)

func TestService_List(t *testing.T) {

	service := scp.NewService(nil)

	assert.NotNil(t, service)

	dir, home := path.Split(os.Getenv("HOME"))
	objects, err := service.List("scp://127.0.0.1/" + dir)
	assert.Nil(t, err)
	for _, object := range objects {
		if strings.HasSuffix(object.URL(), home) {
			assert.True(t, object.IsFolder())
		}
	}

}

func TestService_Delete(t *testing.T) {

	service := scp.NewService(nil)

	assert.NotNil(t, service)

	err := service.Upload("scp://127.0.0.1//tmp/file.txt", strings.NewReader("this is test"))
	assert.Nil(t, err)

	objects, err := service.List("scp://127.0.0.1/tmp/")
	assert.Nil(t, err)
	assert.True(t, len(objects) > 1)

	object, err := service.StorageObject("scp://127.0.0.1//tmp/file.txt")
	assert.Nil(t, err)

	reader, err := service.Download(object)
	if assert.Nil(t, err) {
		content, err := ioutil.ReadAll(reader)
		assert.Nil(t, err)
		assert.Equal(t, "this is test", string(content))
	}

	err = service.Delete(object)
	assert.Nil(t, err)

}<commit_msg>patched file info on linux<commit_after>package scp_test

import (
	"github.com/stretchr/testify/assert"
	"testing"

	"github.com/viant/toolbox/storage/scp"
	"io/ioutil"
	"os"
	"path"
	"strings"
	"github.com/viant/toolbox/storage"
)

func TestService_List(t *testing.T) {

	service := scp.NewService(nil)

	assert.NotNil(t, service)

	dir, home := path.Split(os.Getenv("HOME"))
	objects, err := service.List("scp://127.0.0.1/" + dir)
	assert.Nil(t, err)
	for _, object := range objects {
		if strings.HasSuffix(object.URL(), home) {
			assert.True(t, object.IsFolder())
		}
	}

}

func TestService_Delete(t *testing.T) {

	service := scp.NewService(nil)

	assert.NotNil(t, service)

	err := service.Upload("scp://127.0.0.1//tmp/file.txt", strings.NewReader("this is test"))
	assert.Nil(t, err)

	objects, err := service.List("scp://127.0.0.1/tmp/")
	assert.Nil(t, err)
	assert.True(t, len(objects) > 1)

	object, err := service.StorageObject("scp://127.0.0.1//tmp/file.txt")
	assert.Nil(t, err)

	reader, err := service.Download(object)
	if assert.Nil(t, err) {
		content, err := ioutil.ReadAll(reader)
		assert.Nil(t, err)
		assert.Equal(t, "this is test", string(content))
	}

	err = service.Delete(object)
	assert.Nil(t, err)

}

func Test_ExtractFileInfo(t *testing.T) {

	{
		var object storage.Object = scp.ExtractFileInfo("-rw-r--r--  1 awitas  1742120565   414 Jun  8 14:14:08 2017 f.pub", false)
		assert.Equal(t, "/f.pub", object.URL())
		assert.Equal(t, int64(1496931248), object.LastModified().Unix())
		assert.Equal(t, int64(414), object.Size())
		assert.Equal(t, true, object.IsContent())
	}


	var object storage.Object = scp.ExtractFileInfo("-rw-r--r-- 1 awitas awitas 2002 2017-11-04 22:29:33.363458941 +0000 aerospikeciads_aerospike.conf", true)
	assert.Equal(t, "/aerospikeciads_aerospike.conf", object.URL())
	assert.Equal(t, int64(1509834573), object.LastModified().Unix())
	assert.Equal(t, int64(2002), object.Size())
	assert.Equal(t, true, object.IsContent())

}
{'fraction_non_alphanumeric': 0.18629617934954215, 'fraction_numerical': 0.04483738553836438, 'mean_word_length': 4.19344262295082, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7630903', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1266, 'n_words': 223}